[style] Rubocop
This commit is contained in:
parent
a599980046
commit
1ca58961c1
2 changed files with 10 additions and 10 deletions
|
|
@ -14,9 +14,9 @@ class TicketPurchasesController < ApplicationController
|
||||||
message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first))
|
message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first))
|
||||||
# The new ticket_purchase has been added to the database. current_user.ticket_purchases contains the new one.
|
# The new ticket_purchase has been added to the database. current_user.ticket_purchases contains the new one.
|
||||||
count_registration_tickets_after = current_user.count_registration_tickets(@conference)
|
count_registration_tickets_after = current_user.count_registration_tickets(@conference)
|
||||||
|
|
||||||
# Failed to create ticket purchase
|
# Failed to create ticket purchase
|
||||||
if !message.blank?
|
unless message.blank?
|
||||||
redirect_to conference_tickets_path(@conference.short_title),
|
redirect_to conference_tickets_path(@conference.short_title),
|
||||||
error: "Oops, something went wrong with your purchase! #{message}"
|
error: "Oops, something went wrong with your purchase! #{message}"
|
||||||
return
|
return
|
||||||
|
|
@ -25,15 +25,15 @@ class TicketPurchasesController < ApplicationController
|
||||||
# Current user already paid for a registration ticket and the current ticket purchase contains one
|
# Current user already paid for a registration ticket and the current ticket purchase contains one
|
||||||
if count_registration_tickets_before == 1 && count_registration_tickets_after > 1
|
if count_registration_tickets_before == 1 && count_registration_tickets_after > 1
|
||||||
redirect_to conference_physical_tickets_path,
|
redirect_to conference_physical_tickets_path,
|
||||||
notice: 'You already have tickets for the conference.'
|
notice: 'You already have tickets for the conference.'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# Conference requires a registration ticket but the current user wants to purchase a non-registration ticket
|
# Conference requires a registration ticket but the current user wants to purchase a non-registration ticket
|
||||||
# and does not have a registration ticket
|
# and does not have a registration ticket
|
||||||
if @conference.registration_ticket_required? && count_registration_tickets_after == 0
|
if @conference.registration_ticket_required? && count_registration_tickets_after == 0
|
||||||
redirect_to conference_tickets_path(@conference.short_title),
|
redirect_to conference_tickets_path(@conference.short_title),
|
||||||
error: 'Please get at least one registration ticket to continue.'
|
error: 'Please get at least one registration ticket to continue.'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ class TicketPurchasesController < ApplicationController
|
||||||
# Current user didn't have a registration ticket and is purchasing one
|
# Current user didn't have a registration ticket and is purchasing one
|
||||||
if count_registration_tickets_before == 0 && count_registration_tickets_after == 1
|
if count_registration_tickets_before == 0 && count_registration_tickets_after == 1
|
||||||
redirect_to new_conference_conference_registration_path(@conference.short_title)
|
redirect_to new_conference_conference_registration_path(@conference.short_title)
|
||||||
else
|
else
|
||||||
redirect_to conference_physical_tickets_path
|
redirect_to conference_physical_tickets_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -348,15 +348,15 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
def count_registration_tickets(conference)
|
def count_registration_tickets(conference)
|
||||||
count = 0
|
count = 0
|
||||||
for ticket_purchase in ticket_purchases.by_conference(conference)
|
ticket_purchases.by_conference(conference).each do |ticket_purchase|
|
||||||
for physical_ticket in ticket_purchase.physical_tickets
|
ticket_purchase.physical_tickets.each do |physical_ticket|
|
||||||
if physical_ticket.ticket.registration_ticket
|
if physical_ticket.ticket.registration_ticket
|
||||||
count += 1
|
count += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return count
|
count
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.empty?
|
def self.empty?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue