Sha256: 82509a7c89aff06d8f57567ea6ebedbfd726b3ae0c06e40eff4df62cb14428cf

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

module Spotlight
  class AboutPagesController < PagesController
    load_and_authorize_resource through: :exhibit, instance_name: 'page'
    before_filter :attach_breadcrumbs, except: [:update_contacts]


    def update_contacts
      if @exhibit.update(contact_params)
        redirect_to exhibit_about_pages_path(@exhibit), notice: t(:'helpers.submit.contact.batch_updated')
      else
        render action: 'index'
      end
    end

    protected

    def attach_breadcrumbs
      super
      if @page
        if action_name == 'edit'
          add_breadcrumb t(:'spotlight.pages.index.about_pages.header'), exhibit_about_pages_path(@exhibit)
        else
          add_breadcrumb (@exhibit.main_navigations.about.label_or_default), [@exhibit, @exhibit.main_about_page]
        end

        unless @page == @exhibit.main_about_page
          add_breadcrumb @page.title, action_name == 'edit' ? [:edit, @page.exhibit, @page] : [@page.exhibit, @page] 
        end
      elsif action_name == 'index'
        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
    end

    def contact_params
      params.require(:exhibit).permit("contacts_attributes" => [:id, :show_in_sidebar, :weight])
    end

    def update_all_page_params
      params.require(:exhibit).permit( "about_pages_attributes" => page_attributes)
    end

    def allowed_page_params
      super.concat [:published]
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-spotlight-0.4.1 app/controllers/spotlight/about_pages_controller.rb
blacklight-spotlight-0.3.1 app/controllers/spotlight/about_pages_controller.rb
blacklight-spotlight-0.3.0 app/controllers/spotlight/about_pages_controller.rb
blacklight-spotlight-0.2.0 app/controllers/spotlight/about_pages_controller.rb
blacklight-spotlight-0.1.0 app/controllers/spotlight/about_pages_controller.rb