Sha256: 1d8599e7cc8d9bbe35a1d91faefb181a3816eb85330e46c282342c1fa91f0a94

Contents?: true

Size: 1.19 KB

Versions: 58

Compression:

Stored size: 1.19 KB

Contents

module Hyrax
  class ContactForm
    include ActiveModel::Model
    attr_accessor :contact_method, :category, :name, :email, :subject, :message
    validates :email, :category, :name, :subject, :message, presence: true
    validates :email, format: /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i, allow_blank: true

    # - can't use this without ActiveRecord::Base validates_inclusion_of :category, in: self.class.issue_types_for_locale

    # They should not have filled out the `contact_method' field. That's there to prevent spam.
    def spam?
      contact_method.present?
    end

    # Declare the e-mail headers. It accepts anything the mail method
    # in ActionMailer accepts.
    def headers
      {
        subject: "#{Hyrax.config.subject_prefix} #{subject}",
        to: Hyrax.config.contact_email,
        from: email
      }
    end

    def self.issue_types_for_locale
      [
        I18n.t('hyrax.contact_form.issue_types.depositing'),
        I18n.t('hyrax.contact_form.issue_types.changing'),
        I18n.t('hyrax.contact_form.issue_types.browsing'),
        I18n.t('hyrax.contact_form.issue_types.reporting'),
        I18n.t('hyrax.contact_form.issue_types.general')
      ]
    end
  end
end

Version data entries

58 entries across 58 versions & 2 rubygems

Version Path
hyrax-2.9.6 app/models/hyrax/contact_form.rb
hyrax-2.9.5 app/models/hyrax/contact_form.rb
hyrax-2.9.4 app/models/hyrax/contact_form.rb
hyrax-2.9.3 app/models/hyrax/contact_form.rb
hyrax-2.9.2 app/models/hyrax/contact_form.rb
hyrax-2.9.1 app/models/hyrax/contact_form.rb
hyrax-2.9.0 app/models/hyrax/contact_form.rb
hyrax-2.8.0 app/models/hyrax/contact_form.rb
hyrax-2.7.2 app/models/hyrax/contact_form.rb
hyrax-2.7.1 app/models/hyrax/contact_form.rb
hyrax-2.7.0 app/models/hyrax/contact_form.rb
hyrax-2.6.0 app/models/hyrax/contact_form.rb
hyrax-3.0.0.pre.rc1 app/models/hyrax/contact_form.rb
hyrax-3.0.0.pre.beta3 app/models/hyrax/contact_form.rb
hyrax-2.5.1 app/models/hyrax/contact_form.rb
hyrax-2.5.0 app/models/hyrax/contact_form.rb
hyrax-3.0.0.pre.beta2 app/models/hyrax/contact_form.rb
hyrax-2.4.1 app/models/hyrax/contact_form.rb
hyrax-3.0.0.pre.beta1 app/models/hyrax/contact_form.rb
hyrax-2.4.0 app/models/hyrax/contact_form.rb