Commit 28ce731529a203e00b7744bfe9551efca41c06c1
Committed by
Luciano Prestes
1 parent
be0349f9
Exists in
merge_deactive_and_ban
deactive_and_active_profile: Add deactivate profile on its edit page
(ActionItem3287) Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
2 changed files
with
18 additions
and
0 deletions
Show diff stats
app/controllers/my_profile/profile_editor_controller.rb
... | ... | @@ -78,4 +78,18 @@ class ProfileEditorController < MyProfileController |
78 | 78 | end |
79 | 79 | end |
80 | 80 | end |
81 | + | |
82 | + def deactivate_profile | |
83 | + if environment.admins.include?(current_person) | |
84 | + profile = Profile.find(params[:id]) | |
85 | + | |
86 | + if profile.disable | |
87 | + session[:notice] = _("The profile '#{profile.name}' was disabled.") | |
88 | + else | |
89 | + session[:notice] = _('Could not disable profile.') | |
90 | + end | |
91 | + end | |
92 | + | |
93 | + redirect_to "/" | |
94 | + end | |
81 | 95 | end | ... | ... |
app/views/profile_editor/edit.html.erb
... | ... | @@ -67,6 +67,10 @@ |
67 | 67 | <% if user && user.has_permission?('destroy_profile', profile) %> |
68 | 68 | <% button_bar(:id => 'delete-profile') do %> |
69 | 69 | <%= button(:remove, _('Delete profile'), {:action => :destroy_profile}) %> |
70 | + | |
71 | + <% if environment.admins.include?(current_person) %> | |
72 | + <%= button(:remove, _('Deactivate profile'), {:action => :deactivate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure ?")}) %> | |
73 | + <% end %> | |
70 | 74 | <% end %> |
71 | 75 | <% end %> |
72 | 76 | <% end %> | ... | ... |