Class: DmEvent::RegistrationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- DmEvent::RegistrationsController
- Includes:
- DmCore::LiquidHelper, DmCore::UrlHelper, PermittedParams, OffsitePayments::Integrations
- Defined in:
- app/controllers/dm_event/registrations_controller.rb
Instance Method Summary collapse
-
#choose_payment ⇒ Object
Only allow to proceed with payment if the registration is still in pending ——————————————————————————.
-
#create ⇒ Object
——————————————————————————.
-
#new ⇒ Object
——————————————————————————.
-
#success ⇒ Object
Success page for a registration.
Methods included from PermittedParams
#registration_params, #system_email_params, #workshop_params, #workshop_price_params
Instance Method Details
#choose_payment ⇒ Object
Only allow to proceed with payment if the registration is still in pending
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/dm_event/registrations_controller.rb', line 63 def choose_payment @registration = Registration.find_by_uuid(params[:uuid]) @workshop = @registration.workshop if @registration flash[:alert] = I18n.t('core.resource_invalid') redirect_to main_app.root_url and return if @registration.nil? || !@registration.accepted? if @workshop.require_account raise Account::LoginRequired.new(I18n.t('core.login_required')) if current_user.nil? if @registration.user_profile.user != current_user && !is_admin? flash[:alert] = I18n.t('core.resource_invalid') redirect_to main_app.root_url and return end end if @registration.balance_owed.zero? render :payment_complete and return end end |
#create ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/dm_event/registrations_controller.rb', line 39 def create redirect_to(action: :new) and return if @workshop.require_account && current_user.nil? profile_params = params[:registration].delete("user_profile_attributes") if params[:registration] profile_params.delete(:id) if profile_params @registration = @workshop.registrations.new(registration_params(@workshop)) @registration.registered_locale = I18n.locale @registration.user_profile = current_user ? current_user.user_profile : UserProfile.new @registration.user_profile.assign_attributes(user_profile_direct_params(profile_params)) unless profile_params.blank? if @registration.save if @workshop.payments_enabled? && !@workshop.require_review? && @registration.balance_owed.positive? redirect_to register_choose_payment_url(@registration.uuid) else redirect_to register_success_url(@registration.uuid) end else render action: :new end end |
#new ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/dm_event/registrations_controller.rb', line 18 def new redirect_to main_app.root_url and return if @workshop.nil? if !@workshop.registration_closed? || is_admin? @registration = @workshop.registrations.build @registration.user_profile = current_user ? current_user.user_profile : UserProfile.new if @workshop.require_address && !@registration.user_profile.address_valid? #--- address is required and there are missing fields in the profile @registration.user_profile.address_required = true end @registration.user_profile.userless_registration = true if current_user.nil? && !@workshop.require_account description: @workshop.summary, "og:description" => sanitize_text(markdown(@workshop.summary, safe: false)) "og:image" => site_asset_media_url(@workshop.image) if @workshop.image.present? else render action: :closed end end |
#success ⇒ Object
Success page for a registration. Look up the uuid and display success. Can do this many times - if the user doesn’t own the registration, then kick them out.
86 87 88 89 90 91 92 93 94 95 |
# File 'app/controllers/dm_event/registrations_controller.rb', line 86 def success @registration = Registration.find_by_uuid(params[:uuid]) if @registration.nil? || @registration.user_profile.user != current_user #--- not logged in or not the users registration (for ) flash[:alert] = I18n.t('core.resource_invalid') redirect_to main_app.root_url and return end @workshop = @registration.workshop if @registration @receipt_content = @registration.email_state_notification(@registration.current_state, false) || "" end |