Class: Spotlight::AdminUsersController
Overview
A controller to handle the administration of users
Instance Method Summary
collapse
#enabled_in_spotlight_view_type_configuration?, #field_enabled?
Methods included from Controller
#add_breadcrumb, #blacklight_config, #breadcrumbs, #current_exhibit, #current_masthead, #current_masthead=, #current_site, #default_url_options, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_path, #resource_masthead?, #search_action_url, #search_facet_path, #search_state, #set_exhibit_locale_scope, #set_locale
Methods included from Config
#exhibit_specific_blacklight_config
Instance Method Details
#create ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/spotlight/admin_users_controller.rb', line 18
def create
if update_roles
Spotlight::.call(resource: @site)
flash[:notice] = t('.success')
else
flash[:error] = t('.error')
end
redirect_to spotlight.admin_users_path
end
|
#destroy ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/spotlight/admin_users_controller.rb', line 41
def destroy
user = Spotlight::Engine.user_class.find(params[:id])
if user.roles.where(resource: @site).first.destroy
flash[:notice] = t('.success')
else
flash[:error] = t('.error')
end
redirect_to spotlight.admin_users_path
end
|
#index ⇒ Object
13
14
15
16
|
# File 'app/controllers/spotlight/admin_users_controller.rb', line 13
def index
add_breadcrumb(t(:'spotlight.sites.home'), root_url)
add_breadcrumb(t(:'spotlight.admin_users.index.page_title'))
end
|
#remove_exhibit_roles ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/spotlight/admin_users_controller.rb', line 51
def remove_exhibit_roles
user = Spotlight::Engine.user_class.find(params[:id])
if user.all_exhibit_roles.destroy_all
flash[:notice] = t('.success')
else
flash[:error] = t('.error')
end
redirect_to spotlight.admin_users_path
end
|
#update ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/spotlight/admin_users_controller.rb', line 29
def update
user = Spotlight::Engine.user_class.find(params[:id])
if user
Spotlight::Role.create(user_key: user.email, role: 'admin', resource: @site).save
flash[:notice] = t('spotlight.admin_users.create.success')
else
flash[:error] = t('spotlight.admin_users.create.error')
end
redirect_to spotlight.admin_users_path
end
|