fix conference registration
This commit is contained in:
parent
06cf1ced2b
commit
51d3663769
8 changed files with 23 additions and 26 deletions
|
|
@ -1,9 +1,9 @@
|
|||
class ConferenceRegistrationController < ApplicationController
|
||||
before_filter :verify_user
|
||||
authorize_resource class: false
|
||||
load_and_authorize_resource :conference, find_by: :short_title
|
||||
|
||||
def register
|
||||
# TODO Figure out how to change the route's id from :id to :conference_id
|
||||
@conference = Conference.find_by(short_title: params[:id])
|
||||
@workshops = @conference.events.where('require_registration = ? AND state LIKE ?',
|
||||
true, 'confirmed')
|
||||
@user = current_user
|
||||
|
|
@ -23,9 +23,8 @@ class ConferenceRegistrationController < ApplicationController
|
|||
|
||||
# TODO this is ugly
|
||||
def update
|
||||
conference = Conference.find_by(short_title: params[:id])
|
||||
user = current_user
|
||||
registration = user.registrations.where(conference_id: conference.id).first
|
||||
registration = user.registrations.where(conference_id: @conference.id).first
|
||||
update_registration = true
|
||||
# First verify that the supporter code is legit
|
||||
if !params[:registration][:supporter_registration_attributes].nil? &&
|
||||
|
|
@ -35,9 +34,9 @@ class ConferenceRegistrationController < ApplicationController
|
|||
|
||||
if regs.count != 0
|
||||
if regs.where(email: user.email).count == 0
|
||||
redirect_to(register_conference_path(id: conference.short_title),
|
||||
redirect_to(conference_register_path(conference_id: @conference.short_title),
|
||||
alert: "This code is already in use.
|
||||
Please contact #{conference.contact_email} for assistance.")
|
||||
Please contact #{@conference.contact_email} for assistance.")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
@ -50,7 +49,7 @@ class ConferenceRegistrationController < ApplicationController
|
|||
supporter_reg = params[:registration][:supporter_registration_attributes]
|
||||
params[:registration].delete :supporter_registration_attributes
|
||||
registration = user.registrations.new(registration_params)
|
||||
if conference.use_supporter_levels? && !supporter_reg.nil?
|
||||
if @conference.use_supporter_levels? && !supporter_reg.nil?
|
||||
if !supporter_reg[:id].blank?
|
||||
# Means that their supporter registration was entered ahead of time, by an admin
|
||||
registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id])
|
||||
|
|
@ -58,19 +57,19 @@ class ConferenceRegistrationController < ApplicationController
|
|||
raise 'Invalid code'
|
||||
end
|
||||
else
|
||||
registration.supporter_registration = conference.
|
||||
registration.supporter_registration = @conference.
|
||||
supporter_registrations.new(registration_params[:supporter_registration_attributes])
|
||||
end
|
||||
end
|
||||
|
||||
registration.conference_id = conference.id
|
||||
registration.conference_id = @conference.id
|
||||
registration.save!
|
||||
else
|
||||
registration.update_attributes!(registration_params)
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.debug e.backtrace.join('\n')
|
||||
redirect_to(register_conference_path(id: conference.short_title),
|
||||
redirect_to(conference_register_path(conference_id: @conference.short_title),
|
||||
alert: 'Registration failed:' + e.message)
|
||||
return
|
||||
end
|
||||
|
|
@ -81,18 +80,17 @@ class ConferenceRegistrationController < ApplicationController
|
|||
else
|
||||
# Track ahoy event
|
||||
ahoy.track 'Registered', title: 'New registration'
|
||||
if conference.email_settings.send_on_registration?
|
||||
Mailbot.registration_mail(conference, current_user).deliver
|
||||
if @conference.email_settings.send_on_registration?
|
||||
Mailbot.registration_mail(@conference, current_user).deliver
|
||||
end
|
||||
end
|
||||
redirect_to(register_conference_path(id: conference.short_title),
|
||||
redirect_to(conference_register_path(conference_id: @conference.short_title),
|
||||
notice: redirect_message)
|
||||
end
|
||||
|
||||
def unregister
|
||||
conference = Conference.find_by(short_title: params[:id])
|
||||
user = current_user
|
||||
registration = user.registrations.where(conference_id: conference.id).first
|
||||
registration = user.registrations.where(conference_id: @conference.id).first
|
||||
registration.destroy
|
||||
redirect_to :root
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue