Sha256: 0d315fb9c65be8ae56eb03487e9e6f47d22ffe5862de39ffb30dfebc2246a7e0

Contents?: true

Size: 1.15 KB

Versions: 99

Compression:

Stored size: 1.15 KB

Contents

require "edition"

class LicenceEdition < Edition

  field :licence_identifier,  :type => String
  field :licence_short_description, :type => String
  field :licence_overview,  :type => String
  field :will_continue_on, :type => String
  field :continuation_link, :type => String

  GOVSPEAK_FIELDS = Edition::GOVSPEAK_FIELDS + [:licence_overview]

  validates :licence_identifier, :presence => true
  validate :licence_identifier_unique
  validates_format_of :continuation_link, :with => URI::regexp(%w(http https)), :allow_blank => true
  
  @fields_to_clone = [:licence_identifier, :licence_short_description,
                      :licence_overview, :will_continue_on, :continuation_link]

  def whole_body
    [licence_short_description, licence_overview].join("\n\n")
  end

  def indexable_content
    "#{super} #{licence_short_description} #{Govspeak::Document.new(licence_overview).to_text}".strip
  end

  private
  def licence_identifier_unique
    if self.class.without_state('archived').where(:licence_identifier => licence_identifier,
                        :panopticon_id.ne => panopticon_id).any?
      errors.add(:licence_identifier, :taken)
    end
  end
end

Version data entries

99 entries across 99 versions & 1 rubygems

Version Path
govuk_content_models-28.0.0 app/models/licence_edition.rb
govuk_content_models-27.2.0 app/models/licence_edition.rb
govuk_content_models-27.1.0 app/models/licence_edition.rb
govuk_content_models-27.0.0 app/models/licence_edition.rb
govuk_content_models-26.2.0 app/models/licence_edition.rb
govuk_content_models-26.1.0 app/models/licence_edition.rb
govuk_content_models-26.0.0 app/models/licence_edition.rb
govuk_content_models-25.0.0 app/models/licence_edition.rb
govuk_content_models-24.2.0 app/models/licence_edition.rb
govuk_content_models-24.1.0 app/models/licence_edition.rb
govuk_content_models-24.0.1 app/models/licence_edition.rb
govuk_content_models-24.0.0 app/models/licence_edition.rb
govuk_content_models-23.0.0 app/models/licence_edition.rb
govuk_content_models-22.2.0 app/models/licence_edition.rb
govuk_content_models-22.1.2 app/models/licence_edition.rb
govuk_content_models-22.1.1 app/models/licence_edition.rb
govuk_content_models-22.1.0 app/models/licence_edition.rb
govuk_content_models-22.0.0 app/models/licence_edition.rb
govuk_content_models-21.0.0 app/models/licence_edition.rb
govuk_content_models-20.2.0 app/models/licence_edition.rb