Sha256: 2d2c7260227d2569edb2b3a5834ae2d42283f18d40f21ea847ed4469ae58556d

Contents?: true

Size: 1.97 KB

Versions: 33

Compression:

Stored size: 1.97 KB

Contents

module Spotlight
  ##
  # CRUD actions for exhibit curator contacts (not to be confused with
  # email addresses for receiving feedback messages, see {Spotlight::ExhibitsController})
  class ContactsController < Spotlight::ApplicationController
    before_action :authenticate_user!
    load_and_authorize_resource :exhibit, class: 'Spotlight::Exhibit'
    load_and_authorize_resource through: :exhibit
    before_action :attach_breadcrumbs

    def new
      add_breadcrumb t(:'helpers.action.spotlight/contact.create'), new_exhibit_contact_path(@exhibit)
    end

    def edit
      add_breadcrumb @contact.name, edit_exhibit_contact_path(@contact.exhibit, @contact)
    end

    def update
      if @contact.update(contact_params)
        redirect_to exhibit_about_pages_path(@contact.exhibit), notice: t(:'helpers.submit.contact.updated', model: @contact.class.model_name.human.downcase)
      else
        render 'edit'
      end
    end

    def create
      if @contact.update(contact_params)
        redirect_to exhibit_about_pages_path(@contact.exhibit), notice: t(:'helpers.submit.contact.created', model: @contact.class.model_name.human.downcase)
      else
        render 'new'
      end
    end

    def destroy
      @contact.destroy
      redirect_to exhibit_about_pages_path(@contact.exhibit), notice: t(:'helpers.submit.contact.destroyed', model: @contact.class.model_name.human.downcase)
    end

    protected

    def attach_breadcrumbs
      add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
      add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(@exhibit)
      add_breadcrumb t(:'spotlight.pages.index.about_pages.header'), exhibit_about_pages_path(@exhibit)
    end

    def contact_params
      params.require(:contact).permit(:name,
                                      contact_info: Spotlight::Contact.fields.keys,
                                      avatar_attributes: [:iiif_tilesource, :iiif_region])
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.4.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.3.3 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.3.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.3.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.3.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.2.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.2.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.1.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.0.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.0.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.0.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.0.0.rc6 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.0.0.rc5 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.0.0.rc4 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.0.0.rc3 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.0.0.rc2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.0.0.rc1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-1.5.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-1.4.1 app/controllers/spotlight/contacts_controller.rb