setting-for-account-deletable (#3852)

This commit is contained in:
masarakki
2017-06-19 22:12:31 +09:00
committed by Eugen Rochko
parent 500e28442f
commit ff142eb64d
5 changed files with 28 additions and 3 deletions

View File

@ -3,6 +3,7 @@
class Settings::DeletesController < ApplicationController
layout 'admin'
before_action :check_enabled_deletion
before_action :authenticate_user!
def show
@ -21,6 +22,10 @@ class Settings::DeletesController < ApplicationController
private
def check_enabled_deletion
redirect_to root_path unless Setting.open_deletion
end
def delete_params
params.require(:form_delete_confirmation).permit(:password)
end

View File

@ -13,6 +13,10 @@ module ApplicationHelper
Setting.open_registrations
end
def open_deletion?
Setting.open_deletion
end
def add_rtl_body_class(other_classes)
other_classes = "#{other_classes} rtl" if [:ar, :fa, :he].include?(I18n.locale)
other_classes

View File

@ -12,7 +12,8 @@
.actions
= f.button :button, t('generic.save_changes'), type: :submit
%hr/
- if open_deletion?
%hr/
%h6= t('auth.delete_account')
%p.muted-hint= t('auth.delete_account_html', path: settings_delete_path)
%h6= t('auth.delete_account')
%p.muted-hint= t('auth.delete_account_html', path: settings_delete_path)