From e9bdd2aa5a0662a9fc6d5ce730e26cfd560210ba Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 3 Apr 2017 10:43:42 +0200 Subject: feature: delete user clearing username --- app/controllers/users_controller.rb | 6 +++++- app/helpers/users_helper.rb | 8 ++++++++ app/views/users/_destroy_account.html.haml | 15 ++++++++------- 3 files changed, 21 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0a0f551..da82d1c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -44,7 +44,7 @@ class UsersController < ApplicationController end def destroy - @user.account.destroy + @user.account.destroy(release_handles) flash[:notice] = I18n.t(:account_destroyed) # admins can destroy other users if @user != current_user @@ -65,4 +65,8 @@ class UsersController < ApplicationController params.require(:user).permit(:password, :password_confirmation) end end + + def release_handles + ! params[:block_username] + end end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 1b2dc5d..985f750 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -11,4 +11,12 @@ module UsersHelper end end + + def destroy_account_text + if @user == current_user + t(:destroy_my_account) + else + t(:admin_destroy_account, :username => @user.login) + end + end end diff --git a/app/views/users/_destroy_account.html.haml b/app/views/users/_destroy_account.html.haml index a2c4ddd..66a7dc2 100644 --- a/app/views/users/_destroy_account.html.haml +++ b/app/views/users/_destroy_account.html.haml @@ -3,14 +3,15 @@ -# %legend - - if @user == current_user - = t(:destroy_my_account) - - else - = t(:admin_destroy_account, :username => @user.login) + = destroy_account_text %p= t(:destroy_account_info) -= destroy_btn user_path(@user), :type => "danger" do - %i.icon-remove.icon-white - = t(:destroy_my_account) += form_tag user_path(@user), method: :delete do + .checkbox + = label_tag do + = check_box_tag 'block_username', 1, true + = t(:keep_username_blocked) + = submit_tag destroy_account_text, class: "btn btn-danger" + - if @user != current_user and @user.enabled? %legend = t(:deactivate_account, :username => @user.login) -- cgit v1.2.3