diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4501ebea8..ab554bfd7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -46,6 +46,10 @@ 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) else diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml index f964a5802..98f27236e 100644 --- a/app/views/users/_form.html.haml +++ b/app/views/users/_form.html.haml @@ -32,8 +32,13 @@ = f.label :avatar, t("activerecord.attributes.user.avatar") .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 diff --git a/config/locales/users.en.yml b/config/locales/users.en.yml index 4328e808b..fd860f5e4 100644 --- a/config/locales/users.en.yml +++ b/config/locales/users.en.yml @@ -22,6 +22,7 @@ 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 activerecord: attributes: diff --git a/config/locales/users.ru.yml b/config/locales/users.ru.yml index 3ba4f318d..954664993 100644 --- a/config/locales/users.ru.yml +++ b/config/locales/users.ru.yml @@ -22,6 +22,7 @@ ru: delete_warning: Внимание! Удаленный аккаунт восстановлению не подлежит. private_settings_header: Изменение пароля avatar_notice: При отсутствии загруженной аватарки будет использована Ваша аватарка на сервисе gravatar. + delete_avatar: Удалить аватар activerecord: attributes: