Sha256: 02b2e027cf2ad86d8577084f31ae3353a8ac0d7dac6f42fb12f1f60fded26c7e

Contents?: true

Size: 1.13 KB

Versions: 27

Compression:

Stored size: 1.13 KB

Contents

module Spotlight
  ##
  # Exhibit curator contact information
  class Contact < ActiveRecord::Base
    belongs_to :exhibit, touch: true, optional: true
    scope :published, -> { where(show_in_sidebar: true) }
    default_scope { order('weight ASC') }
    serialize :contact_info, Hash

    extend FriendlyId
    friendly_id :name, use: [:slugged, :scoped, :finders], scope: :exhibit

    belongs_to :avatar, class_name: 'Spotlight::ContactImage', dependent: :destroy, optional: true
    accepts_nested_attributes_for :avatar, update_only: true, reject_if: proc { |attr| attr['iiif_tilesource'].blank? }

    before_save do
      self.contact_info = contact_info.symbolize_keys
    end

    before_save on: :create do
      self.show_in_sidebar = true if show_in_sidebar.nil?
    end

    def self.fields
      @fields ||= { title: { itemprop: 'jobTitle' },
                    location: { itemprop: 'workLocation' },
                    email: { helper: :render_contact_email_address },
                    telephone: {} }
    end

    protected

    def should_generate_new_friendly_id?
      super || (name_changed? && persisted?)
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

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