Class: Admin::UsersController

Inherits:
AdminController show all
Defined in:
app/controllers/admin/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#close_accountObject


7
8
9
10
11
# File 'app/controllers/admin/users_controller.rb', line 7

def 
  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_accountObject


13
14
15
16
17
# File 'app/controllers/admin/users_controller.rb', line 13

def 
  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_adminObject


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_moderatorObject


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_spotlightObject


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_adminObject


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_moderatorObject


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_spotlightObject


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_accountObject


19
20
21
22
23
# File 'app/controllers/admin/users_controller.rb', line 19

def 
  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