registration#delete: retain ticket purchases
This commit is contained in:
parent
85fcd4e1b7
commit
d1c0c7d97a
5 changed files with 55 additions and 28 deletions
|
|
@ -29,7 +29,6 @@ class Registration < ActiveRecord::Base
|
|||
validate :registration_to_events_only_if_present
|
||||
|
||||
after_create :set_week, :subscribe_to_conference, :send_registration_mail
|
||||
after_destroy :destroy_purchased_tickets
|
||||
|
||||
##
|
||||
# Makes a list of events that includes (in that order):
|
||||
|
|
@ -60,11 +59,6 @@ class Registration < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def destroy_purchased_tickets
|
||||
ticket_purchased = TicketPurchase.where(conference_id: conference_id, user_id: user.id)
|
||||
ticket_purchased.destroy_all
|
||||
end
|
||||
|
||||
def subscribe_to_conference
|
||||
Subscription.create(conference_id: conference.id, user_id: user.id)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -116,8 +116,12 @@
|
|||
-if @registration
|
||||
.btn-group-vertical.pull-right
|
||||
= link_to 'Edit your Registration', edit_conference_conference_registration_path(@conference.short_title), class: 'btn btn-success', disabled: @conference.end_date < Date.today
|
||||
= link_to 'Unregister', conference_conference_registration_path(@conference.short_title),
|
||||
method: :delete, class: 'btn btn-danger btn-xs', confirm: 'Are you sure you want to unregister?', disabled: @conference.end_date < Date.today
|
||||
- if @tickets.any?
|
||||
= link_to 'Unregister', conference_conference_registration_path(@conference.short_title), method: :delete, class: 'btn btn-danger btn-xs',
|
||||
data: { confirm: "Your ticket purchases won't be refunded. Are you sure you want to unregister?" }, disabled: @conference.end_date < Date.today
|
||||
- else
|
||||
= link_to 'Unregister', conference_conference_registration_path(@conference.short_title), method: :delete, class: 'btn btn-danger btn-xs',
|
||||
data: { confirm: "You haven't purchased any ticket. Are you sure you want to unregister?" }, disabled: @conference.end_date < Date.today
|
||||
- else
|
||||
= link_to 'Register', new_conference_conference_registration_path(@conference.short_title), class: 'btn btn-success btn-lg pull-right'
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,11 @@
|
|||
= button_tag(type: 'submit', class: 'btn btn-success btn-lg') do
|
||||
Continue
|
||||
%i.fa.fa-shopping-cart
|
||||
= link_to 'Cancel registration', conference_conference_registration_path(@conference.short_title), method: :delete, class: 'btn btn-danger btn-sm'
|
||||
- if current_user.ticket_purchases.by_conference(@conference).any?
|
||||
= link_to 'Back to registration', conference_conference_registration_path(@conference.short_title), class: 'btn btn-default btn-sm'
|
||||
- else
|
||||
= link_to 'Cancel registration', conference_conference_registration_path(@conference.short_title), method: :delete, class: 'btn btn-danger btn-sm',
|
||||
data: { confirm: 'Are you sure you want to unregister?' }
|
||||
.row
|
||||
.col-md-13
|
||||
%p.text-muted.text-center
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue