Sha256: aa1019706c0be82b5dc7f385a2714b92ed7e7ec4c95adbb49c606ddd527362b2

Contents?: true

Size: 1.59 KB

Versions: 20

Compression:

Stored size: 1.59 KB

Contents

module Effective
  class EventRegistrationsController < ApplicationController
    if defined?(Devise)
      before_action :authenticate_user!, unless: -> { action_name == 'new' || (action_name == 'show' && params[:id] == 'start') }
    end

    include Effective::WizardController

    before_action :redirect_unless_registerable, only: [:new, :show]
    before_action :expire_ticket_selection_window, only: [:show]

    resource_scope -> {
      event = Effective::Event.find(params[:event_id])
      EffectiveEvents.EventRegistration.deep.where(owner: current_user, event: event)
    }

    # If the event is no longer registerable, do not let them continue
    def redirect_unless_registerable
      return if resource.blank?
      return if resource.was_submitted?
      return if resource.event.blank?
      return if resource.submit_order&.deferred?
      return if resource.event.registerable? && !resource.event.sold_out?(except: resource)

      flash[:danger] = "Your selected event is no longer available for registration. This event registration is no longer available."
      return redirect_to(view_context.return_to_dashboard_path)
    end

    def expire_ticket_selection_window
      return if resource.blank?
      return if resource.was_submitted?
      return if resource.event.blank?
      return if resource.selection_not_expired?

      resource.ticket_selection_expired!

      flash[:danger] = "Your ticket reservation window has expired. Your tickets are no longer reserved. Please start over."

      return redirect_to(wizard_path(:start))
    end

    # TODO: Add better permitted params

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
effective_events-2.29.0 app/controllers/effective/event_registrations_controller.rb
effective_events-2.28.3 app/controllers/effective/event_registrations_controller.rb
effective_events-2.28.2 app/controllers/effective/event_registrations_controller.rb
effective_events-2.28.1 app/controllers/effective/event_registrations_controller.rb
effective_events-2.28.0 app/controllers/effective/event_registrations_controller.rb
effective_events-2.27.0 app/controllers/effective/event_registrations_controller.rb
effective_events-2.26.0 app/controllers/effective/event_registrations_controller.rb
effective_events-2.25.1 app/controllers/effective/event_registrations_controller.rb
effective_events-2.25.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.24.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.23.1 app/controllers/effective/event_registrations_controller.rb
effective_events-0.23.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.22.2 app/controllers/effective/event_registrations_controller.rb
effective_events-0.22.1 app/controllers/effective/event_registrations_controller.rb
effective_events-0.22.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.21.3 app/controllers/effective/event_registrations_controller.rb
effective_events-0.21.2 app/controllers/effective/event_registrations_controller.rb
effective_events-0.21.1 app/controllers/effective/event_registrations_controller.rb
effective_events-0.21.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.20.6 app/controllers/effective/event_registrations_controller.rb