modify ticket purchases view
This commit is contained in:
parent
92dc0edff2
commit
1894cea975
3 changed files with 9 additions and 26 deletions
|
|
@ -4,11 +4,11 @@ class TicketPurchasesController < ApplicationController
|
||||||
authorize_resource :conference_registrations, class: Registration
|
authorize_resource :conference_registrations, class: Registration
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
TicketPurchase.by_conference(@conference).unpaid.by_user(current_user).destroy_all
|
||||||
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
|
message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0])
|
||||||
if message.blank?
|
if message.blank?
|
||||||
if current_user.ticket_purchases.any?
|
if current_user.ticket_purchases.by_conference(@conference).unpaid.any?
|
||||||
redirect_to conference_conference_registration_path(@conference.short_title),
|
redirect_to new_conference_payment_path, notice: 'Please pay here to purchase tickets.'
|
||||||
notice: "Thank you for supporting #{@conference.title} by purchasing a ticket."
|
|
||||||
else
|
else
|
||||||
redirect_to conference_conference_registration_path(@conference.short_title)
|
redirect_to conference_conference_registration_path(@conference.short_title)
|
||||||
end
|
end
|
||||||
|
|
@ -18,18 +18,6 @@ class TicketPurchasesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
|
||||||
@ticket_purchases = current_user.ticket_purchases.find(params[:id])
|
|
||||||
if @ticket_purchases.destroy
|
|
||||||
redirect_to conference_conference_registration_path(@conference.short_title),
|
|
||||||
notice: 'Ticket successfully deleted.'
|
|
||||||
else
|
|
||||||
redirect_to conference_conference_registration_path(@conference.short_title),
|
|
||||||
error: 'An error prohibited deleting your purchase! '\
|
|
||||||
"#{@ticket_purchases.errors.full_messages.join('. ')}."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def ticket_purchase_params
|
def ticket_purchase_params
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,8 @@
|
||||||
- unless ticket.description.blank?
|
- unless ticket.description.blank?
|
||||||
= markdown(ticket.description)
|
= markdown(ticket.description)
|
||||||
%td.col-sm-1.col-md-1
|
%td.col-sm-1.col-md-1
|
||||||
- if ticket.bought?(current_user)
|
= text_field_tag("tickets[][#{ticket.id}]", 0,
|
||||||
= text_field_tag("tickets[][#{ticket.id}]", ticket.quantity_bought_by(current_user),
|
|
||||||
type: 'number', min: 0, class: "form-control quantity", 'data-id' => ticket.id)
|
type: 'number', min: 0, class: "form-control quantity", 'data-id' => ticket.id)
|
||||||
- else
|
|
||||||
= text_field_tag("tickets[][#{ticket.id}]", 0, type: 'number', min: 0,
|
|
||||||
class: "form-control quantity", 'data-id' => ticket.id)
|
|
||||||
%td.col-sm-1.col-md-1.text-center
|
%td.col-sm-1.col-md-1.text-center
|
||||||
= ticket.price.symbol
|
= ticket.price.symbol
|
||||||
%span{id: "price_#{ticket.id}"}
|
%span{id: "price_#{ticket.id}"}
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
%h1
|
%h1
|
||||||
Tickets
|
Tickets
|
||||||
%p.lead
|
%p.lead
|
||||||
If you like, support
|
Please choose your tickets for
|
||||||
%strong
|
%strong
|
||||||
= @conference.title
|
= @conference.title
|
||||||
by buying a ticket*
|
here*
|
||||||
=form_tag(conference_ticket_purchases_path, method: :post) do |f|
|
=form_tag(conference_ticket_purchases_path, method: :post) do |f|
|
||||||
%table.table.table-hover
|
%table.table.table-hover
|
||||||
%thead
|
%thead
|
||||||
|
|
@ -35,12 +35,11 @@
|
||||||
.pull-right
|
.pull-right
|
||||||
.btn-group-vertical
|
.btn-group-vertical
|
||||||
= button_tag(type: 'submit', class: 'btn btn-success btn-lg') do
|
= button_tag(type: 'submit', class: 'btn btn-success btn-lg') do
|
||||||
Support
|
Continue
|
||||||
%i.fa.fa-shopping-cart
|
%i.fa.fa-shopping-cart
|
||||||
= link_to 'Continue without a Ticket!', conference_conference_registration_path(@conference.short_title),
|
= link_to 'Cancel registration', conference_conference_registration_path(@conference.short_title), method: :delete, class: 'btn btn-danger btn-sm'
|
||||||
class: 'btn btn-danger btn-sm'
|
|
||||||
.row
|
.row
|
||||||
.col-md-13
|
.col-md-13
|
||||||
%p.text-muted.text-center
|
%p.text-muted.text-center
|
||||||
%small
|
%small
|
||||||
* Buying a ticket is not mandatory. Checkout will be at the conference registration.
|
* Buying a ticket is mandatory. Your registration will not complete until you buy a ticket.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue