Sha256: 650548b3e2a847f26fe69b8b397e09f9d677368e2a58a41a801d8786e8a2b38c

Contents?: true

Size: 2 KB

Versions: 16

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 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 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 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

16 entries across 16 versions & 1 rubygems

Version Path
blacklight-spotlight-4.1.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-4.1.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-4.1.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-4.0.3 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-4.0.2 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-4.0.1 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-4.0.0 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.6.0.beta10 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.6.0.beta9 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.6.0.beta8 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.6.0.beta7 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.6.0.beta6 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.6.0.beta5 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.6.0.beta4 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.6.0.beta3 app/controllers/spotlight/contacts_controller.rb
blacklight-spotlight-3.6.0.beta1 app/controllers/spotlight/contacts_controller.rb