Sha256: 52ae1dc2383b080b9ac509d2b021a8e16c36643c2e1c170fd0637a7db53fc68c

Contents?: true

Size: 2 KB

Versions: 34

Compression:

Stored size: 2 KB

Contents

# frozen_string_literal: true

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: %i[iiif_tilesource iiif_region])
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
blacklight-spotlight-3.5.0.4 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.5.0.3 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.5.0.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.5.0.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.5.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.4.4.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.4.4 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.4.3 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.4.2.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.4.2.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.4.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.4.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.4.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.3.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.2.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.1.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.0.3 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.0.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.0.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.0.0 app/controllers/spotlight/contacts_controller.rb