Sha256: 953836d7e077299123e2da2f839fd5f35cfda21e9ccc61a392db3d12984e755e

Contents?: true

Size: 1.1 KB

Versions: 76

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Spotlight
  ##
  # Controller for routing exhibit feedback from users
  class ContactFormsController < Spotlight::ApplicationController
    load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
    before_action :build_contact_form

    def new
      @contact_form.current_url = request.referer
    end

    def create
      if @contact_form.valid?
        ContactMailer.report_problem(@contact_form).deliver_now

        redirect_back fallback_location: spotlight.new_exhibit_contact_form_path(current_exhibit), notice: t(:'helpers.submit.contact_form.created')
      else
        render 'new'
      end
    end

    protected

    def build_contact_form
      @contact_form = Spotlight::ContactForm.new(contact_form_params)
      @contact_form.current_exhibit = current_exhibit
      @contact_form.request = request
      @contact_form
    end

    def contact_form_params
      return {} if params[:action] == 'new'

      params.require(:contact_form).permit(:name, :email, Spotlight::Engine.config.spambot_honeypot_email_field, :message, :current_url)
    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
blacklight-spotlight-3.5.0.3 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.6.0.beta6 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.6.0.beta5 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.6.0.beta4 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.6.0.beta3 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.6.0.beta1 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.5.0.2 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.5.0.1 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.5.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.4.4.1 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.4.4 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.4.3 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.4.2.2 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.4.2.1 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.4.2 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.4.1 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.4.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.3.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.2.0 app/controllers/spotlight/contact_forms_controller.rb
blacklight-spotlight-3.1.0 app/controllers/spotlight/contact_forms_controller.rb