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
|
class ConferenceRegistrationController < ApplicationController
|
||||||
before_filter :verify_user
|
before_filter :verify_user
|
||||||
|
authorize_resource class: false
|
||||||
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
|
||||||
def register
|
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 ?',
|
@workshops = @conference.events.where('require_registration = ? AND state LIKE ?',
|
||||||
true, 'confirmed')
|
true, 'confirmed')
|
||||||
@user = current_user
|
@user = current_user
|
||||||
|
|
@ -23,9 +23,8 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
|
|
||||||
# TODO this is ugly
|
# TODO this is ugly
|
||||||
def update
|
def update
|
||||||
conference = Conference.find_by(short_title: params[:id])
|
|
||||||
user = current_user
|
user = current_user
|
||||||
registration = user.registrations.where(conference_id: conference.id).first
|
registration = user.registrations.where(conference_id: @conference.id).first
|
||||||
update_registration = true
|
update_registration = true
|
||||||
# First verify that the supporter code is legit
|
# First verify that the supporter code is legit
|
||||||
if !params[:registration][:supporter_registration_attributes].nil? &&
|
if !params[:registration][:supporter_registration_attributes].nil? &&
|
||||||
|
|
@ -35,9 +34,9 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
|
|
||||||
if regs.count != 0
|
if regs.count != 0
|
||||||
if regs.where(email: user.email).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.
|
alert: "This code is already in use.
|
||||||
Please contact #{conference.contact_email} for assistance.")
|
Please contact #{@conference.contact_email} for assistance.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -50,7 +49,7 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
supporter_reg = params[:registration][:supporter_registration_attributes]
|
supporter_reg = params[:registration][:supporter_registration_attributes]
|
||||||
params[:registration].delete :supporter_registration_attributes
|
params[:registration].delete :supporter_registration_attributes
|
||||||
registration = user.registrations.new(registration_params)
|
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?
|
if !supporter_reg[:id].blank?
|
||||||
# Means that their supporter registration was entered ahead of time, by an admin
|
# Means that their supporter registration was entered ahead of time, by an admin
|
||||||
registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id])
|
registration.supporter_registration = SupporterRegistration.find(supporter_reg[:id])
|
||||||
|
|
@ -58,19 +57,19 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
raise 'Invalid code'
|
raise 'Invalid code'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
registration.supporter_registration = conference.
|
registration.supporter_registration = @conference.
|
||||||
supporter_registrations.new(registration_params[:supporter_registration_attributes])
|
supporter_registrations.new(registration_params[:supporter_registration_attributes])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
registration.conference_id = conference.id
|
registration.conference_id = @conference.id
|
||||||
registration.save!
|
registration.save!
|
||||||
else
|
else
|
||||||
registration.update_attributes!(registration_params)
|
registration.update_attributes!(registration_params)
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
Rails.logger.debug e.backtrace.join('\n')
|
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)
|
alert: 'Registration failed:' + e.message)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
@ -81,18 +80,17 @@ class ConferenceRegistrationController < ApplicationController
|
||||||
else
|
else
|
||||||
# Track ahoy event
|
# Track ahoy event
|
||||||
ahoy.track 'Registered', title: 'New registration'
|
ahoy.track 'Registered', title: 'New registration'
|
||||||
if conference.email_settings.send_on_registration?
|
if @conference.email_settings.send_on_registration?
|
||||||
Mailbot.registration_mail(conference, current_user).deliver
|
Mailbot.registration_mail(@conference, current_user).deliver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to(register_conference_path(id: conference.short_title),
|
redirect_to(conference_register_path(conference_id: @conference.short_title),
|
||||||
notice: redirect_message)
|
notice: redirect_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unregister
|
def unregister
|
||||||
conference = Conference.find_by(short_title: params[:id])
|
|
||||||
user = current_user
|
user = current_user
|
||||||
registration = user.registrations.where(conference_id: conference.id).first
|
registration = user.registrations.where(conference_id: @conference.id).first
|
||||||
registration.destroy
|
registration.destroy
|
||||||
redirect_to :root
|
redirect_to :root
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,6 @@ class ProposalController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirm
|
def confirm
|
||||||
authorize! :update, @event
|
|
||||||
@url = conference_proposal_path(@conference.short_title, params[:id])
|
@url = conference_proposal_path(@conference.short_title, params[:id])
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
-else
|
-else
|
||||||
%h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
|
%h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
|
||||||
- if @conference.registration_open?
|
- if @conference.registration_open?
|
||||||
= link_to "Register for #{@conference.short_title}", register_conference_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank'
|
= link_to "Register for #{@conference.short_title}", conference_register_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank'
|
||||||
- if @conference.use_supporter_levels?
|
- if @conference.use_supporter_levels?
|
||||||
- if @conference.include_tickets_in_splash?
|
- if @conference.include_tickets_in_splash?
|
||||||
= render 'tickets'
|
= render 'tickets'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= semantic_form_for(@registration, :url => register_conference_path(@conference.short_title), :html => { :method => :patch }) do |f|
|
= semantic_form_for(@registration, :url => conference_register_path(@conference.short_title), :html => { :method => :patch }) do |f|
|
||||||
.tabbable
|
.tabbable
|
||||||
%ul.nav.nav-tabs
|
%ul.nav.nav-tabs
|
||||||
%li.active
|
%li.active
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
= render 'conference_registration/volunteer', :f => f
|
= render 'conference_registration/volunteer', :f => f
|
||||||
- if @registered
|
- if @registered
|
||||||
= f.action :submit, :button_html => { :value => "Update Registration", :class => "btn btn-primary" }
|
= f.action :submit, :button_html => { :value => "Update Registration", :class => "btn btn-primary" }
|
||||||
= link_to "Unregister", register_conference_path(@conference.short_title),:method => :delete, :class => "btn btn-danger",
|
= link_to "Unregister", conference_register_path(@conference.short_title),:method => :delete, :class => "btn btn-danger",
|
||||||
:confirm => "Are you sure you want to unregister?"
|
:confirm => "Are you sure you want to unregister?"
|
||||||
- else
|
- else
|
||||||
= f.action :submit, :button_html => { :value => "Register", :class => "btn btn-primary", id: 'register' }
|
= f.action :submit, :button_html => { :value => "Register", :class => "btn btn-primary", id: 'register' }
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@
|
||||||
= link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default"
|
||||||
- if conference.registration_open?
|
- if conference.registration_open?
|
||||||
- if conference.user_registered?(current_user)
|
- if conference.user_registered?(current_user)
|
||||||
= link_to "Modify Registration", register_conference_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "Modify Registration", conference_register_path(conference.short_title), :class =>"btn btn-default"
|
||||||
- else
|
- else
|
||||||
= link_to "Register", register_conference_path(conference.short_title), :class =>"btn btn-success"
|
= link_to "Register", conference_register_path(conference.short_title), :class =>"btn btn-success"
|
||||||
= link_to "Schedule", conference_schedule_path(conference.short_title), :class =>"btn btn-default" if conference.call_for_papers and conference.call_for_papers.schedule_public
|
= link_to "Schedule", conference_schedule_path(conference.short_title), :class =>"btn btn-default" if conference.call_for_papers and conference.call_for_papers.schedule_public
|
||||||
- if !current_user.nil? && current_user.proposal_count(conference) > 0
|
- if !current_user.nil? && current_user.proposal_count(conference) > 0
|
||||||
= link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
|
= link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
(Pre-registered: #{pre_registered(event).count})
|
(Pre-registered: #{pre_registered(event).count})
|
||||||
- if event.confirmed? && !@conference.user_registered?(current_user)
|
- if event.confirmed? && !@conference.user_registered?(current_user)
|
||||||
%br
|
%br
|
||||||
= link_to "Register to attend", register_conference_path(@conference.short_title), :style => "font-size:10px;"
|
= link_to "Register to attend", conference_register_path(@conference.short_title), :style => "font-size:10px;"
|
||||||
%td
|
%td
|
||||||
.pull-right
|
.pull-right
|
||||||
- if event.transition_possible? :confirm
|
- if event.transition_possible? :confirm
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
%span.label{:style =>"background-color: #{@event.difficulty_level.color};"}
|
%span.label{:style =>"background-color: #{@event.difficulty_level.color};"}
|
||||||
= @event.difficulty_level.title
|
= @event.difficulty_level.title
|
||||||
- if @event.require_registration
|
- if @event.require_registration
|
||||||
= link_to "Registration required!", register_conference_path(@conference.short_title), :class => "btn btn-xs btn-warning"
|
= link_to "Registration required!", conference_register_path(@conference.short_title), :class => "btn btn-xs btn-warning"
|
||||||
.col-md-9
|
.col-md-9
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,10 @@ Osem::Application.routes.draw do
|
||||||
resource :schedule, only: [] do
|
resource :schedule, only: [] do
|
||||||
get "/" => "schedule#index"
|
get "/" => "schedule#index"
|
||||||
end
|
end
|
||||||
|
get "/register" => "conference_registration#register"
|
||||||
|
patch "/register" => "conference_registration#update"
|
||||||
|
delete "/register" => "conference_registration#unregister"
|
||||||
member do
|
member do
|
||||||
get "/register" => "conference_registration#register"
|
|
||||||
patch "/register" => "conference_registration#update"
|
|
||||||
delete "/register" => "conference_registration#unregister"
|
|
||||||
get "gallery_photos"
|
get "gallery_photos"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue