Sha256: c6b34779b71912081818a89ae948aa79d30afd6ed920dc0d38ad00e3f9ab66b1

Contents?: true

Size: 1 KB

Versions: 15

Compression:

Stored size: 1 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]

    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.event.registerable?
      return if resource.submit_order&.deferred?

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

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
effective_events-0.19.2 app/controllers/effective/event_registrations_controller.rb
effective_events-0.19.1 app/controllers/effective/event_registrations_controller.rb
effective_events-0.19.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.18.2 app/controllers/effective/event_registrations_controller.rb
effective_events-0.18.1 app/controllers/effective/event_registrations_controller.rb
effective_events-0.18.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.17.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.16.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.15.1 app/controllers/effective/event_registrations_controller.rb
effective_events-0.15.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.14.2 app/controllers/effective/event_registrations_controller.rb
effective_events-0.14.1 app/controllers/effective/event_registrations_controller.rb
effective_events-0.14.0 app/controllers/effective/event_registrations_controller.rb
effective_events-0.13.1 app/controllers/effective/event_registrations_controller.rb
effective_events-0.13.0 app/controllers/effective/event_registrations_controller.rb