fix conference registration

This commit is contained in:
Stella Rouzi 2014-07-13 11:42:46 +03:00
parent 06cf1ced2b
commit 51d3663769
8 changed files with 23 additions and 26 deletions

View file

@ -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

View file

@ -105,7 +105,6 @@ class ProposalController < ApplicationController
end
def confirm
authorize! :update, @event
@url = conference_proposal_path(@conference.short_title, params[:id])
begin

View file

@ -13,7 +13,7 @@
-else
%h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
- 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.include_tickets_in_splash?
= render 'tickets'

View file

@ -1,6 +1,6 @@
.row
.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
%ul.nav.nav-tabs
%li.active
@ -16,7 +16,7 @@
= render 'conference_registration/volunteer', :f => f
- if @registered
= 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?"
- else
= f.action :submit, :button_html => { :value => "Register", :class => "btn btn-primary", id: 'register' }

View file

@ -25,9 +25,9 @@
= link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default"
- if conference.registration_open?
- 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
= 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
- 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"

View file

@ -27,7 +27,7 @@
(Pre-registered: #{pre_registered(event).count})
- if event.confirmed? && !@conference.user_registered?(current_user)
%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
.pull-right
- if event.transition_possible? :confirm

View file

@ -37,7 +37,7 @@
%span.label{:style =>"background-color: #{@event.difficulty_level.color};"}
= @event.difficulty_level.title
- 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
.row
.col-md-12

View file

@ -88,10 +88,10 @@ Osem::Application.routes.draw do
resource :schedule, only: [] do
get "/" => "schedule#index"
end
get "/register" => "conference_registration#register"
patch "/register" => "conference_registration#update"
delete "/register" => "conference_registration#unregister"
member do
get "/register" => "conference_registration#register"
patch "/register" => "conference_registration#update"
delete "/register" => "conference_registration#unregister"
get "gallery_photos"
end
end