mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
setting-for-account-deletable (#3852)
This commit is contained in:
parent
500e28442f
commit
ff142eb64d
@ -3,6 +3,7 @@
|
|||||||
class Settings::DeletesController < ApplicationController
|
class Settings::DeletesController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
|
||||||
|
before_action :check_enabled_deletion
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@ -21,6 +22,10 @@ class Settings::DeletesController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def check_enabled_deletion
|
||||||
|
redirect_to root_path unless Setting.open_deletion
|
||||||
|
end
|
||||||
|
|
||||||
def delete_params
|
def delete_params
|
||||||
params.require(:form_delete_confirmation).permit(:password)
|
params.require(:form_delete_confirmation).permit(:password)
|
||||||
end
|
end
|
||||||
|
@ -13,6 +13,10 @@ module ApplicationHelper
|
|||||||
Setting.open_registrations
|
Setting.open_registrations
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def open_deletion?
|
||||||
|
Setting.open_deletion
|
||||||
|
end
|
||||||
|
|
||||||
def add_rtl_body_class(other_classes)
|
def add_rtl_body_class(other_classes)
|
||||||
other_classes = "#{other_classes} rtl" if [:ar, :fa, :he].include?(I18n.locale)
|
other_classes = "#{other_classes} rtl" if [:ar, :fa, :he].include?(I18n.locale)
|
||||||
other_classes
|
other_classes
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
.actions
|
.actions
|
||||||
= f.button :button, t('generic.save_changes'), type: :submit
|
= f.button :button, t('generic.save_changes'), type: :submit
|
||||||
|
|
||||||
%hr/
|
- if open_deletion?
|
||||||
|
%hr/
|
||||||
|
|
||||||
%h6= t('auth.delete_account')
|
%h6= t('auth.delete_account')
|
||||||
%p.muted-hint= t('auth.delete_account_html', path: settings_delete_path)
|
%p.muted-hint= t('auth.delete_account_html', path: settings_delete_path)
|
||||||
|
@ -14,6 +14,7 @@ defaults: &defaults
|
|||||||
site_contact_email: ''
|
site_contact_email: ''
|
||||||
open_registrations: true
|
open_registrations: true
|
||||||
closed_registrations_message: ''
|
closed_registrations_message: ''
|
||||||
|
open_deletion: true
|
||||||
boost_modal: false
|
boost_modal: false
|
||||||
auto_play_gif: true
|
auto_play_gif: true
|
||||||
delete_modal: true
|
delete_modal: true
|
||||||
|
@ -68,5 +68,19 @@ describe Settings::DeletesController do
|
|||||||
expect(response).to redirect_to '/auth/sign_in'
|
expect(response).to redirect_to '/auth/sign_in'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context do
|
||||||
|
around do |example|
|
||||||
|
open_deletion = Setting.open_deletion
|
||||||
|
example.run
|
||||||
|
Setting.open_deletion = open_deletion
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'redirects' do
|
||||||
|
Setting.open_deletion = false
|
||||||
|
delete :destroy
|
||||||
|
expect(response).to redirect_to root_path
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user