Merge pull request #292 from warpc/257-new_design_for_profiles
[Refs #257] * add ability to destroy avatar; * fixed translation; * force convert avatar to jpg; * fixed 'big' geometry
This commit is contained in:
commit
c84e61c51e
|
@ -25,7 +25,8 @@ class UsersController < ApplicationController
|
|||
@user = User.new
|
||||
end
|
||||
|
||||
def edit
|
||||
def profile
|
||||
@user ||= current_user
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -46,12 +47,16 @@ class UsersController < ApplicationController
|
|||
end
|
||||
@user ||= current_user
|
||||
if @user.update_without_password(params[:user])
|
||||
if @user.avatar && params[:delete_avatar] == '1'
|
||||
@user.avatar = nil
|
||||
@user.save
|
||||
end
|
||||
flash[:notice] = t('flash.user.saved')
|
||||
redirect_to edit_user_path(@user)
|
||||
redirect_to @user == current_user ? edit_profile_path : edit_user_path(@user)
|
||||
else
|
||||
flash[:error] = t('flash.user.save_error')
|
||||
flash[:warning] = @user.errors.full_messages.join('. ')
|
||||
render(:action => :edit)
|
||||
render(:action => :profile)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Ability
|
|||
|
||||
if user.user?
|
||||
can [:show, :autocomplete_user_uname], User
|
||||
can [:edit, :update, :private], User, :id => user.id
|
||||
can [:profile, :update, :private], User, :id => user.id
|
||||
|
||||
can [:show, :update], Settings::Notifier, :user_id => user.id
|
||||
|
||||
|
|
|
@ -3,8 +3,15 @@ class User < ActiveRecord::Base
|
|||
ROLES = ['admin']
|
||||
LANGUAGES_FOR_SELECT = [['Russian', 'ru'], ['English', 'en']]
|
||||
LANGUAGES = LANGUAGES_FOR_SELECT.map(&:last)
|
||||
MAX_AVATAR_SIZE = 5.megabyte
|
||||
|
||||
has_attached_file :avatar, :styles => { :micro => "16x16", :small => "30x30>", :medium => "40x40>", :big => "81x81" }
|
||||
has_attached_file :avatar, :styles =>
|
||||
{ :micro => { :geometry => "16x16", :format => :jpg, :convert_options => '-strip -background white -flatten -quality 70'},
|
||||
:small => { :geometry => "30x30>", :format => :jpg, :convert_options => '-strip -background white -flatten -quality 70'},
|
||||
:medium => { :geometry => "40x40>", :format => :jpg, :convert_options => '-strip -background white -flatten -quality 70'},
|
||||
:big => { :geometry => "81x81>", :format => :jpg, :convert_options => '-strip -background white -flatten -quality 70'}
|
||||
}
|
||||
validates_inclusion_of :avatar_file_size, :in => (0..MAX_AVATAR_SIZE), :allow_nil => true
|
||||
|
||||
devise :database_authenticatable, :registerable, #:omniauthable, # :token_authenticatable, :encryptable, :timeoutable
|
||||
:recoverable, :rememberable, :validatable #, :trackable, :confirmable, :lockable
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
.droplist-wrap
|
||||
#droplist.droplist
|
||||
.a= link_to current_user.uname, current_user
|
||||
.a= link_to t('layout.settings.label'), edit_user_registration_path
|
||||
.a= link_to t('layout.settings.label'), edit_profile_path
|
||||
.a= link_to t('layout.logout'), destroy_user_session_path, :method => :delete
|
||||
.right
|
||||
.both
|
||||
|
|
|
@ -29,11 +29,16 @@
|
|||
= f.text_field :location
|
||||
.both
|
||||
.leftlist
|
||||
= f.label :avatar, t("activerecord.attributes.user.avatar")
|
||||
= f.label :avatar, t("layout.users.avatar_with_size", :max => number_to_human_size(User::MAX_AVATAR_SIZE))
|
||||
.rightlist
|
||||
= image_tag(avatar_url(@user, :medium))
|
||||
%br
|
||||
%br
|
||||
.leftlist
|
||||
.rightlist
|
||||
.check
|
||||
%span#niceCheckbox1.niceCheck-main
|
||||
= check_box_tag "delete_avatar", 1, false, :class => 'niceCheckbox1'
|
||||
.forcheck= t('layout.users.delete_avatar')
|
||||
.both
|
||||
= f.file_field :avatar
|
||||
.both
|
||||
.leftlist
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
%ul
|
||||
- if can? :edit, @user
|
||||
%li{:class => (act == :edit && :users == contr) ? 'active' : ''}
|
||||
= link_to t("layout.users.edit"), edit_user_path(@user)
|
||||
= link_to t("layout.users.edit"), @user == current_user ? edit_profile_path : edit_user_path(@user)
|
||||
- if can? :private, @user
|
||||
%li{:class => (act == :private && contr == :users) ? 'active' : ''}
|
||||
= link_to t("layout.users.user_private_settings"), user_private_settings_path(@user)
|
||||
|
|
|
@ -3,7 +3,7 @@ en:
|
|||
users:
|
||||
list: List
|
||||
new: Create
|
||||
edit: Edit
|
||||
edit: Profile
|
||||
settings: Settings
|
||||
new_header: New user
|
||||
edit_header: Edit
|
||||
|
@ -23,6 +23,8 @@ en:
|
|||
delete_warning: Warning! Deleted account can not be recovered.
|
||||
private_settings_header: Password change
|
||||
avatar_notice: Without uploaded avatar will be used avatar from gravar web service.
|
||||
delete_avatar: Delete avatar
|
||||
avatar_with_size: Avatar (less than %{max})
|
||||
|
||||
activerecord:
|
||||
attributes:
|
||||
|
@ -45,4 +47,4 @@ en:
|
|||
location: Location
|
||||
company: Company
|
||||
avatar: Avatar
|
||||
|
||||
avatar_file_size: Avatar file size
|
||||
|
|
|
@ -3,7 +3,7 @@ ru:
|
|||
users:
|
||||
list: Список
|
||||
new: Создать
|
||||
edit: Редактировать
|
||||
edit: Профиль
|
||||
settings: Настройки
|
||||
new_header: Новый пользователь
|
||||
edit_header: Редактировать
|
||||
|
@ -23,6 +23,8 @@ ru:
|
|||
delete_warning: Внимание! Удаленный аккаунт восстановлению не подлежит.
|
||||
private_settings_header: Изменение пароля
|
||||
avatar_notice: При отсутствии загруженной аватарки будет использована Ваша аватарка на сервисе gravatar.
|
||||
delete_avatar: Удалить аватар
|
||||
avatar_with_size: Аватар (менее %{max})
|
||||
|
||||
activerecord:
|
||||
attributes:
|
||||
|
@ -41,8 +43,8 @@ ru:
|
|||
password: Пароль
|
||||
password_confirm: Повторите пароль
|
||||
professional_experience: Профессиональный опыт
|
||||
site: Вэб-сайт
|
||||
site: Веб-сайт
|
||||
location: Местонахождение
|
||||
company: Компания
|
||||
avatar: Аватар
|
||||
|
||||
avatar_file_size: Размер аватара
|
||||
|
|
|
@ -3,11 +3,19 @@ Rosa::Application.routes.draw do
|
|||
# XML RPC
|
||||
match 'api/xmlrpc' => 'rpc#xe_index'
|
||||
|
||||
put '/users' => 'users#update'
|
||||
devise_scope :user do
|
||||
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
||||
end
|
||||
devise_for :users, :controllers => {:omniauth_callbacks => 'users/omniauth_callbacks'}
|
||||
devise_for :users, :controllers => {:omniauth_callbacks => 'users/omniauth_callbacks'}, :skip => [:registrations] do
|
||||
get '/users/cancel' => 'devise/registrations#cancel', :as => 'cancel_user_registration'
|
||||
post '/users' => 'devise/registrations#create', :as => 'user_registration'
|
||||
get '/users/sign_up' => 'devise/registrations#new', :as => 'new_user_registration'
|
||||
delete '/users' => 'devise/registrations#destroy'
|
||||
get '/user' => 'users#profile', :as => 'edit_profile'
|
||||
put '/user' => 'users#update', :as => 'update_profile'
|
||||
get '/users/:id' => 'users#profile', :as => 'edit_user'
|
||||
put '/users/:id' => 'users#update', :as => 'update_user'
|
||||
end
|
||||
|
||||
resources :users do
|
||||
resources :groups, :only => [:new, :create, :index]
|
||||
|
|
Loading…
Reference in New Issue