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
|
@user = User.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def profile
|
||||||
|
@user ||= current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -46,12 +47,16 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
@user ||= current_user
|
@user ||= current_user
|
||||||
if @user.update_without_password(params[: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')
|
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
|
else
|
||||||
flash[:error] = t('flash.user.save_error')
|
flash[:error] = t('flash.user.save_error')
|
||||||
flash[:warning] = @user.errors.full_messages.join('. ')
|
flash[:warning] = @user.errors.full_messages.join('. ')
|
||||||
render(:action => :edit)
|
render(:action => :profile)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Ability
|
||||||
|
|
||||||
if user.user?
|
if user.user?
|
||||||
can [:show, :autocomplete_user_uname], 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
|
can [:show, :update], Settings::Notifier, :user_id => user.id
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,15 @@ class User < ActiveRecord::Base
|
||||||
ROLES = ['admin']
|
ROLES = ['admin']
|
||||||
LANGUAGES_FOR_SELECT = [['Russian', 'ru'], ['English', 'en']]
|
LANGUAGES_FOR_SELECT = [['Russian', 'ru'], ['English', 'en']]
|
||||||
LANGUAGES = LANGUAGES_FOR_SELECT.map(&:last)
|
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
|
devise :database_authenticatable, :registerable, #:omniauthable, # :token_authenticatable, :encryptable, :timeoutable
|
||||||
:recoverable, :rememberable, :validatable #, :trackable, :confirmable, :lockable
|
:recoverable, :rememberable, :validatable #, :trackable, :confirmable, :lockable
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
.droplist-wrap
|
.droplist-wrap
|
||||||
#droplist.droplist
|
#droplist.droplist
|
||||||
.a= link_to current_user.uname, current_user
|
.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
|
.a= link_to t('layout.logout'), destroy_user_session_path, :method => :delete
|
||||||
.right
|
.right
|
||||||
.both
|
.both
|
||||||
|
|
|
@ -29,11 +29,16 @@
|
||||||
= f.text_field :location
|
= f.text_field :location
|
||||||
.both
|
.both
|
||||||
.leftlist
|
.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
|
.rightlist
|
||||||
= image_tag(avatar_url(@user, :medium))
|
= image_tag(avatar_url(@user, :medium))
|
||||||
%br
|
.leftlist
|
||||||
%br
|
.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
|
= f.file_field :avatar
|
||||||
.both
|
.both
|
||||||
.leftlist
|
.leftlist
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
%ul
|
%ul
|
||||||
- if can? :edit, @user
|
- if can? :edit, @user
|
||||||
%li{:class => (act == :edit && :users == contr) ? 'active' : ''}
|
%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
|
- if can? :private, @user
|
||||||
%li{:class => (act == :private && contr == :users) ? 'active' : ''}
|
%li{:class => (act == :private && contr == :users) ? 'active' : ''}
|
||||||
= link_to t("layout.users.user_private_settings"), user_private_settings_path(@user)
|
= link_to t("layout.users.user_private_settings"), user_private_settings_path(@user)
|
||||||
|
|
|
@ -3,7 +3,7 @@ en:
|
||||||
users:
|
users:
|
||||||
list: List
|
list: List
|
||||||
new: Create
|
new: Create
|
||||||
edit: Edit
|
edit: Profile
|
||||||
settings: Settings
|
settings: Settings
|
||||||
new_header: New user
|
new_header: New user
|
||||||
edit_header: Edit
|
edit_header: Edit
|
||||||
|
@ -23,6 +23,8 @@ en:
|
||||||
delete_warning: Warning! Deleted account can not be recovered.
|
delete_warning: Warning! Deleted account can not be recovered.
|
||||||
private_settings_header: Password change
|
private_settings_header: Password change
|
||||||
avatar_notice: Without uploaded avatar will be used avatar from gravar web service.
|
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:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
|
@ -45,4 +47,4 @@ en:
|
||||||
location: Location
|
location: Location
|
||||||
company: Company
|
company: Company
|
||||||
avatar: Avatar
|
avatar: Avatar
|
||||||
|
avatar_file_size: Avatar file size
|
||||||
|
|
|
@ -3,7 +3,7 @@ ru:
|
||||||
users:
|
users:
|
||||||
list: Список
|
list: Список
|
||||||
new: Создать
|
new: Создать
|
||||||
edit: Редактировать
|
edit: Профиль
|
||||||
settings: Настройки
|
settings: Настройки
|
||||||
new_header: Новый пользователь
|
new_header: Новый пользователь
|
||||||
edit_header: Редактировать
|
edit_header: Редактировать
|
||||||
|
@ -23,6 +23,8 @@ ru:
|
||||||
delete_warning: Внимание! Удаленный аккаунт восстановлению не подлежит.
|
delete_warning: Внимание! Удаленный аккаунт восстановлению не подлежит.
|
||||||
private_settings_header: Изменение пароля
|
private_settings_header: Изменение пароля
|
||||||
avatar_notice: При отсутствии загруженной аватарки будет использована Ваша аватарка на сервисе gravatar.
|
avatar_notice: При отсутствии загруженной аватарки будет использована Ваша аватарка на сервисе gravatar.
|
||||||
|
delete_avatar: Удалить аватар
|
||||||
|
avatar_with_size: Аватар (менее %{max})
|
||||||
|
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
|
@ -41,8 +43,8 @@ ru:
|
||||||
password: Пароль
|
password: Пароль
|
||||||
password_confirm: Повторите пароль
|
password_confirm: Повторите пароль
|
||||||
professional_experience: Профессиональный опыт
|
professional_experience: Профессиональный опыт
|
||||||
site: Вэб-сайт
|
site: Веб-сайт
|
||||||
location: Местонахождение
|
location: Местонахождение
|
||||||
company: Компания
|
company: Компания
|
||||||
avatar: Аватар
|
avatar: Аватар
|
||||||
|
avatar_file_size: Размер аватара
|
||||||
|
|
|
@ -3,11 +3,19 @@ Rosa::Application.routes.draw do
|
||||||
# XML RPC
|
# XML RPC
|
||||||
match 'api/xmlrpc' => 'rpc#xe_index'
|
match 'api/xmlrpc' => 'rpc#xe_index'
|
||||||
|
|
||||||
put '/users' => 'users#update'
|
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
|
||||||
end
|
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 :users do
|
||||||
resources :groups, :only => [:new, :create, :index]
|
resources :groups, :only => [:new, :create, :index]
|
||||||
|
|
Loading…
Reference in New Issue