Class: Spotlight::RolesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spotlight/roles_controller.rb

Overview

CRUD actions for assigning exhibit roles to existing users

Instance Method Summary collapse

Methods included from Concerns::ApplicationController

#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

#indexObject



12
13
14
15
16
17
18
19
# File 'app/controllers/spotlight/roles_controller.rb', line 12

def index
  role = @exhibit.roles.build
  authorize! :edit, role

  add_breadcrumb(t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit)
  add_breadcrumb(t(:'spotlight.configuration.sidebar.header'), exhibit_dashboard_path(@exhibit))
  add_breadcrumb(t(:'spotlight.configuration.sidebar.users'), exhibit_roles_path(@exhibit))
end

#update_allObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/spotlight/roles_controller.rb', line 21

def update_all
  authorize_nested_attributes! exhibit_params[:roles_attributes], Role

  if @exhibit.update(exhibit_params)
    notice = any_deleted ? t(:'helpers.submit.role.destroyed') : t(:'helpers.submit.role.updated')
    Spotlight::InviteUsersService.call(resource: @exhibit)
    redirect_to exhibit_roles_path(@exhibit), notice:
  else
    flash[:alert] = t(:'helpers.submit.role.batch_error', count: exhibit_params[:roles_attributes].to_unsafe_h.size)
    render action: 'index'
  end
end