Add warnings when a user needs to register or complete a purchase
This commit is contained in:
parent
5bef4b7004
commit
1964522f49
4 changed files with 41 additions and 1 deletions
|
|
@ -27,6 +27,10 @@ class ConferencesController < ApplicationController
|
||||||
redirect_to admin_conference_splashpage_path(@conference.short_title) && return
|
redirect_to admin_conference_splashpage_path(@conference.short_title) && return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# User messages at the top of the page.
|
||||||
|
@unpaid_tickets = current_user_has_unpaid_tickets?
|
||||||
|
@user_needs_to_register = current_user_needs_to_register?
|
||||||
|
|
||||||
@image_url = "#{request.protocol}#{request.host}#{@conference.picture}"
|
@image_url = "#{request.protocol}#{request.host}#{@conference.picture}"
|
||||||
|
|
||||||
if splashpage.include_cfp
|
if splashpage.include_cfp
|
||||||
|
|
@ -79,4 +83,17 @@ class ConferencesController < ApplicationController
|
||||||
format.html { head :ok }
|
format.html { head :ok }
|
||||||
end if request.options?
|
end if request.options?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_user_tickets
|
||||||
|
@current_user_tickets ||= current_user.ticket_purchases.by_conference(@conference)
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_user_needs_to_register?
|
||||||
|
current_user && !@conference.user_registered?(current_user) &&
|
||||||
|
current_user_tickets.where(ticket: @conference.registration_tickets).paid.any?
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_user_has_unpaid_tickets?
|
||||||
|
current_user && current_user_tickets.unpaid.any?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class Conference < ApplicationRecord
|
||||||
# True when there is at least one ticket marked as "registration"
|
# True when there is at least one ticket marked as "registration"
|
||||||
# A user must get a registration ticket before registering.
|
# A user must get a registration ticket before registering.
|
||||||
def registration_ticket_required?
|
def registration_ticket_required?
|
||||||
tickets.for_registration.any?
|
registration_tickets.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,28 @@
|
||||||
= content_for :title do
|
= content_for :title do
|
||||||
= @conference.title
|
= @conference.title
|
||||||
|
|
||||||
|
= content_for :additional_messages do
|
||||||
|
- if @unpaid_tickets
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.alert.alert-dismissable.alert-info.text-center#unpaid-tickets{role: 'alert'}
|
||||||
|
%button.button.close{"data-dismiss" => "alert", "aria-label"=>"close"}
|
||||||
|
×
|
||||||
|
%p
|
||||||
|
You have unpaid tickets. Please complete your purchase.
|
||||||
|
= link_to('Purchase Tickets', new_conference_payment_path(@conference), class: 'btn btn-success btn-lg')
|
||||||
|
|
||||||
|
|
||||||
|
- if @user_needs_to_register
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.alert.alert-dismissable.alert-warning.text-center#flash{role: 'alert'}
|
||||||
|
%button.button.close{"data-dismiss" => "alert", 'aria-label': 'close'}
|
||||||
|
×
|
||||||
|
%p
|
||||||
|
You still need to complete your registration for #{@conference.title}.
|
||||||
|
= link_to('Complete Registration', new_conference_conference_registration_path(@conference), class: 'btn btn-success btn-lg')
|
||||||
|
|
||||||
|
|
||||||
#splash
|
#splash
|
||||||
- if @conference.code_of_conduct.present?
|
- if @conference.code_of_conduct.present?
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#messages
|
#messages
|
||||||
.container
|
.container
|
||||||
= render 'layouts/messages'
|
= render 'layouts/messages'
|
||||||
|
= yield :additional_messages
|
||||||
#content
|
#content
|
||||||
= yield
|
= yield
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue