Various small fixes for the participant UI

This commit is contained in:
Henne Vogelsang 2014-12-05 16:04:34 +01:00
parent b6abe96279
commit d13efa5f52
31 changed files with 287 additions and 279 deletions

View file

@ -9,24 +9,22 @@ class ConferenceRegistrationsController < ApplicationController
end
def show
@workshops = @registration.workshops if @registration
@workshops = @registration.workshops
@total_price = Ticket.total_price(@conference, current_user)
@tickets = current_user.ticket_purchases.where(conference_id: 1)
end
def edit; end
def create
user_attributes = registration_params[:user_attributes]
params[:registration].delete :user_attributes
@registration = current_user.registrations.build(registration_params)
@registration.conference_id = @conference.id
if @registration.save && current_user.update_attributes(user_attributes)
if @registration.save
# Trigger ahoy event
ahoy.track 'Registered', title: 'New registration'
if @conference.tickets.any?
if @conference.tickets.any? && !current_user.supports?(@conference)
redirect_to conference_tickets_path(@conference.short_title),
notice: 'You are now registered and will be receiving E-Mail notifications.'
else
@ -66,6 +64,9 @@ class ConferenceRegistrationsController < ApplicationController
def set_registration
@registration = current_user.registrations.find_by(conference_id: @conference.id)
if !@registration
redirect_to new_conference_conference_registrations_path(@conference.short_title)
end
end
def registration_params

View file

@ -6,9 +6,12 @@ class TicketPurchasesController < ApplicationController
def create
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
if message.blank?
redirect_to conference_conference_registrations_path(@conference.short_title),
notice: 'Congratulations, you have successfully purchased a ticket! ' \
"You can pay for it in cash when you arrive! Thank you for supporting #{@conference.title}!"
if current_user.ticket_purchases.any?
redirect_to conference_conference_registrations_path(@conference.short_title),
notice: "Thank you for supporting #{@conference.title} by purchasing a ticket."
else
redirect_to conference_conference_registrations_path(@conference.short_title)
end
else
redirect_to conference_conference_registrations_path(@conference.short_title),
alert: "Oops, something went wrong with your purchase! #{message}"
@ -16,7 +19,7 @@ class TicketPurchasesController < ApplicationController
end
def destroy
@ticket_purchases = current_user.ticket_purchases.find_by(ticket_id: params[:id])
@ticket_purchases = current_user.ticket_purchases.find(params[:id])
if @ticket_purchases.destroy
redirect_to conference_conference_registrations_path(@conference.short_title),
notice: 'Ticket successfully deleted.'