Sha256: 5d019d787374ff55e43e69384dec90d0263271364284d0af0ca33cccf06d07e7

Contents?: true

Size: 2 KB

Versions: 18

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.0.0.alpha.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.13.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.12.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.12.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.11.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.10.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.9.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.8.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.7.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.7.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.7.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.6.1.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.6.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.6.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.5.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.5.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-2.5.0 app/controllers/spotlight/contacts_controller.rb