parent
9b8f2bbcbe
commit
caf2e2a242
11 changed files with 205 additions and 130 deletions
|
@ -47,6 +47,7 @@ class Ability
|
|||
can [:new, :create, :reply, :show, :inbox, :outbox, :mark, :destroy], Message
|
||||
can [:close, :reopen], Note
|
||||
can [:show, :edit, :update], :preference
|
||||
can [:edit, :update], :profile
|
||||
can [:new, :create], Report
|
||||
can [:mine, :new, :create, :edit, :update, :destroy], Trace
|
||||
can [:account, :go_public], User
|
||||
|
|
|
@ -129,9 +129,9 @@ class ConfirmationsController < ApplicationController
|
|||
# display a message about th current status of the gravatar setting
|
||||
def gravatar_status_message(user)
|
||||
if user.image_use_gravatar
|
||||
t "users.account.gravatar.enabled"
|
||||
t "profiles.edit.gravatar.enabled"
|
||||
else
|
||||
t "users.account.gravatar.disabled"
|
||||
t "profiles.edit.gravatar.disabled"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
43
app/controllers/profiles_controller.rb
Normal file
43
app/controllers/profiles_controller.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
class ProfilesController < ApplicationController
|
||||
layout "site"
|
||||
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
|
||||
authorize_resource :class => false
|
||||
|
||||
before_action :check_database_readable
|
||||
before_action :check_database_writable, :only => [:update]
|
||||
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if params[:user][:description] != current_user.description
|
||||
current_user.description = params[:user][:description]
|
||||
current_user.description_format = "markdown"
|
||||
end
|
||||
|
||||
case params[:avatar_action]
|
||||
when "new"
|
||||
current_user.avatar.attach(params[:user][:avatar])
|
||||
current_user.image_use_gravatar = false
|
||||
when "delete"
|
||||
current_user.avatar.purge_later
|
||||
current_user.image_use_gravatar = false
|
||||
when "gravatar"
|
||||
current_user.avatar.purge_later
|
||||
current_user.image_use_gravatar = true
|
||||
end
|
||||
|
||||
current_user.home_lat = params[:user][:home_lat]
|
||||
current_user.home_lon = params[:user][:home_lon]
|
||||
|
||||
if current_user.save
|
||||
flash[:notice] = t ".success"
|
||||
redirect_to user_path(current_user)
|
||||
else
|
||||
flash[:error] = t ".failure"
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
end
|
|
@ -363,26 +363,6 @@ class UsersController < ApplicationController
|
|||
user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
|
||||
end
|
||||
|
||||
if params[:user][:description] != user.description
|
||||
user.description = params[:user][:description]
|
||||
user.description_format = "markdown"
|
||||
end
|
||||
|
||||
case params[:avatar_action]
|
||||
when "new"
|
||||
user.avatar.attach(params[:user][:avatar])
|
||||
user.image_use_gravatar = false
|
||||
when "delete"
|
||||
user.avatar.purge_later
|
||||
user.image_use_gravatar = false
|
||||
when "gravatar"
|
||||
user.avatar.purge_later
|
||||
user.image_use_gravatar = true
|
||||
end
|
||||
|
||||
user.home_lat = params[:user][:home_lat]
|
||||
user.home_lon = params[:user][:home_lon]
|
||||
|
||||
if params[:user][:auth_provider].nil? || params[:user][:auth_provider].blank?
|
||||
user.auth_provider = nil
|
||||
user.auth_uid = nil
|
||||
|
|
61
app/views/profiles/edit.html.erb
Normal file
61
app/views/profiles/edit.html.erb
Normal file
|
@ -0,0 +1,61 @@
|
|||
<% content_for :head do %>
|
||||
<%= javascript_include_tag "user" %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :heading do %>
|
||||
<h1><%= t ".title" %></h1>
|
||||
<% end %>
|
||||
|
||||
<%= bootstrap_form_for current_user, :url => { :action => :update }, :html => { :multipart => true, :autocomplete => :off } do |f| %>
|
||||
<%= f.richtext_field :description, :cols => 80, :rows => 20 %>
|
||||
|
||||
<fieldset class="form-group">
|
||||
<%= f.label t(".image") %>
|
||||
<div class="form-row">
|
||||
<div class="col-sm-2">
|
||||
<%= user_image current_user %>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<% if current_user.avatar.attached? %>
|
||||
<%= f.radio_button "avatar_action", "keep", :name => "avatar_action", :label => t(".keep image"), :checked => !current_user.image_use_gravatar %>
|
||||
<% end %>
|
||||
<% if current_user.avatar.attached? || current_user.image_use_gravatar? %>
|
||||
<%= f.radio_button "avatar_action", "delete", :name => "avatar_action", :label => t(".delete image"), :checked => false %>
|
||||
<% end %>
|
||||
<% if current_user.avatar.attached? %>
|
||||
<%= f.form_group :help => t(".image size hint"), :class => "mb-0" do %>
|
||||
<%= f.radio_button "avatar_action", "new", :name => "avatar_action", :label => t(".replace image"), :checked => false %>
|
||||
<%= f.file_field :avatar, :hide_label => true, :wrapper => { :class => "mb-0" } %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= f.form_group :help => t(".image size hint"), :class => "mb-0" do %>
|
||||
<%= f.radio_button "avatar_action", "new", :name => "avatar_action", :label => t(".new image"), :checked => false %>
|
||||
<%= f.file_field :avatar, :hide_label => true, :wrapper => { :class => "mb-0" } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= f.form_group :help => link_to(t(".gravatar.what_is_gravatar"), t(".gravatar.link")) do %>
|
||||
<%= f.radio_button "avatar_action", "gravatar", :name => "avatar_action", :label => t(".gravatar.gravatar"), :checked => current_user.image_use_gravatar %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend><%= t ".home location" -%></legend>
|
||||
<div id="homerow" <% unless current_user.home_lat and current_user.home_lon %> class="nohome"<% end %>>
|
||||
<p class="message text-muted"><%= t ".no home location" %></p>
|
||||
<div class="form-row">
|
||||
<%= f.text_field :home_lat, :wrapper_class => "col-sm-4", :id => "home_lat" %>
|
||||
<%= f.text_field :home_lon, :wrapper_class => "col-sm-4", :id => "home_lon" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="updatehome" value="1" <% unless current_user.home_lat and current_user.home_lon %> checked="checked" <% end %> id="updatehome" />
|
||||
<label class="form-check-label" for="updatehome"><%= t ".update home location on click" %></label>
|
||||
</div>
|
||||
<%= tag.div "", :id => "map", :class => "content_map set_location" %>
|
||||
</fieldset>
|
||||
|
||||
<%= f.primary t(".save") %>
|
||||
<%= link_to t(".cancel"), user_path(current_user), :class => "btn btn-link" %>
|
||||
<% end %>
|
|
@ -58,55 +58,6 @@
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<%= f.richtext_field :description, :cols => 80, :rows => 20 %>
|
||||
|
||||
<fieldset class="form-group">
|
||||
<%= f.label t(".image") %>
|
||||
<div class="form-row">
|
||||
<div class="col-sm-2">
|
||||
<%= user_image current_user %>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<% if current_user.avatar.attached? %>
|
||||
<%= f.radio_button "avatar_action", "keep", :name => "avatar_action", :label => t(".keep image"), :checked => !current_user.image_use_gravatar %>
|
||||
<% end %>
|
||||
<% if current_user.avatar.attached? || current_user.image_use_gravatar? %>
|
||||
<%= f.radio_button "avatar_action", "delete", :name => "avatar_action", :label => t(".delete image"), :checked => false %>
|
||||
<% end %>
|
||||
<% if current_user.avatar.attached? %>
|
||||
<%= f.form_group :help => t(".image size hint"), :class => "mb-0" do %>
|
||||
<%= f.radio_button "avatar_action", "new", :name => "avatar_action", :label => t(".replace image"), :checked => false %>
|
||||
<%= f.file_field :avatar, :hide_label => true, :wrapper => { :class => "mb-0" } %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= f.form_group :help => t(".image size hint"), :class => "mb-0" do %>
|
||||
<%= f.radio_button "avatar_action", "new", :name => "avatar_action", :label => t(".new image"), :checked => false %>
|
||||
<%= f.file_field :avatar, :hide_label => true, :wrapper => { :class => "mb-0" } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= f.form_group :help => link_to(t(".gravatar.what_is_gravatar"), t(".gravatar.link")) do %>
|
||||
<%= f.radio_button "avatar_action", "gravatar", :name => "avatar_action", :label => t(".gravatar.gravatar"), :checked => current_user.image_use_gravatar %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend><%= t ".home location" -%></legend>
|
||||
<div id="homerow" <% unless current_user.home_lat and current_user.home_lon %> class="nohome"<% end %>>
|
||||
<p class="message text-muted"><%= t ".no home location" %></p>
|
||||
<div class="form-row">
|
||||
<%= f.text_field :home_lat, :wrapper_class => "col-sm-4", :id => "home_lat" %>
|
||||
<%= f.text_field :home_lon, :wrapper_class => "col-sm-4", :id => "home_lon" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="updatehome" value="1" <% unless current_user.home_lat and current_user.home_lon %> checked="checked" <% end %> id="updatehome" />
|
||||
<label class="form-check-label" for="updatehome"><%= t ".update home location on click" %></label>
|
||||
</div>
|
||||
<%= tag.div "", :id => "map", :class => "content_map set_location" %>
|
||||
</fieldset>
|
||||
|
||||
<%= f.primary t(".save changes button") %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -165,6 +165,12 @@
|
|||
|
||||
<div class="user-description richtext text-break"><%= @user.description.to_html %></div>
|
||||
|
||||
<% if current_user and @user.id == current_user.id %>
|
||||
<div class="my-3">
|
||||
<%= link_to t(".edit_profile"), edit_profile_path, :class => "btn btn-outline-primary" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
<% if current_user and current_user.administrator? -%>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue