diff options
author | masarakki <masaki182@gmail.com> | 2017-06-19 22:12:31 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-06-19 15:12:31 +0200 |
commit | ff142eb64d2d1251f9df1baa0b302fd532ec30ed (patch) | |
tree | 66c9e30ddef330ae32d3b0adb75983bf38bc0a4b /app | |
parent | 500e28442f8e6657de766fbdb4a4cfdb164b2b92 (diff) |
setting-for-account-deletable (#3852)
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/settings/deletes_controller.rb | 5 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
-rw-r--r-- | app/views/auth/registrations/edit.html.haml | 7 |
3 files changed, 13 insertions, 3 deletions
diff --git a/app/controllers/settings/deletes_controller.rb b/app/controllers/settings/deletes_controller.rb index dd18b4c2f..80002b995 100644 --- a/app/controllers/settings/deletes_controller.rb +++ b/app/controllers/settings/deletes_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 42f6ab3db..36c37fae0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/views/auth/registrations/edit.html.haml b/app/views/auth/registrations/edit.html.haml index cbaa75ae0..38d4349cb 100644 --- a/app/views/auth/registrations/edit.html.haml +++ b/app/views/auth/registrations/edit.html.haml @@ -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) |