Class: Admin::UsersController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- ApplicationController
- AdminController
- Admin::UsersController
- Defined in:
- app/controllers/admin/users_controller.rb
Instance Method Summary collapse
- #close_account ⇒ Object
- #lock_account ⇒ Object
- #make_admin ⇒ Object
- #make_moderator ⇒ Object
- #make_spotlight ⇒ Object
- #remove_admin ⇒ Object
- #remove_moderator ⇒ Object
- #remove_spotlight ⇒ Object
- #unlock_account ⇒ Object
Instance Method Details
#close_account ⇒ Object
7 8 9 10 11 |
# File 'app/controllers/admin/users_controller.rb', line 7 def close_account u = User.find(params[:id]) u.close_account! redirect_to user_search_path, notice: t("admins.user_search.account_closing_scheduled", name: u.username) end |
#lock_account ⇒ Object
13 14 15 16 17 |
# File 'app/controllers/admin/users_controller.rb', line 13 def lock_account u = User.find(params[:id]) u.lock_access! redirect_to user_search_path, notice: t("admins.user_search.account_locking_scheduled", name: u.username) end |
#make_admin ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/admin/users_controller.rb', line 25 def make_admin unless Role.is_admin? @user.person Role.add_admin @user.person notice = "admins.user_search.add_admin" else notice = "admins.user_search.role_implemented" end redirect_to user_search_path, notice: t(notice, name: @user.username) end |
#make_moderator ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/admin/users_controller.rb', line 45 def make_moderator unless Role.moderator_only? @user.person Role.add_moderator @user.person notice = "admins.user_search.add_moderator" else notice = "admins.user_search.role_implemented" end redirect_to user_search_path, notice: t(notice, name: @user.username) end |
#make_spotlight ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/admin/users_controller.rb', line 65 def make_spotlight unless Role.spotlight? @user.person Role.add_spotlight @user.person notice = "admins.user_search.add_spotlight" else notice = "admins.user_search.role_implemented" end redirect_to user_search_path, notice: t(notice, name: @user.username) end |
#remove_admin ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/admin/users_controller.rb', line 35 def remove_admin if Role.is_admin? @user.person Role.remove_admin @user.person notice = "admins.user_search.delete_admin" else notice = "admins.user_search.role_removal_implemented" end redirect_to user_search_path, notice: t(notice, name: @user.username) end |
#remove_moderator ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/admin/users_controller.rb', line 55 def remove_moderator if Role.moderator_only? @user.person Role.remove_moderator @user.person notice = "admins.user_search.delete_moderator" else notice = "admins.user_search.role_removal_implemented" end redirect_to user_search_path, notice: t(notice, name: @user.username) end |
#remove_spotlight ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/admin/users_controller.rb', line 75 def remove_spotlight if Role.spotlight? @user.person Role.remove_spotlight @user.person notice = "admins.user_search.delete_spotlight" else notice = "admins.user_search.role_removal_implemented" end redirect_to user_search_path, notice: t(notice, name: @user.username) end |
#unlock_account ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/admin/users_controller.rb', line 19 def unlock_account u = User.find(params[:id]) u.unlock_access! redirect_to user_search_path, notice: t("admins.user_search.account_unlocking_scheduled", name: u.username) end |