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,4 +78,18 @@ class ProfileEditorController < MyProfileController | ||
78 | end | 78 | end |
79 | end | 79 | end |
80 | end | 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 | end | 95 | end |
app/views/profile_editor/edit.html.erb
@@ -67,6 +67,10 @@ | @@ -67,6 +67,10 @@ | ||
67 | <% if user && user.has_permission?('destroy_profile', profile) %> | 67 | <% if user && user.has_permission?('destroy_profile', profile) %> |
68 | <% button_bar(:id => 'delete-profile') do %> | 68 | <% button_bar(:id => 'delete-profile') do %> |
69 | <%= button(:remove, _('Delete profile'), {:action => :destroy_profile}) %> | 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 | <% end %> | 74 | <% end %> |
71 | <% end %> | 75 | <% end %> |
72 | <% end %> | 76 | <% end %> |