Refactoring Tickets

- Tickets now independent from registration
- Implemented money gem
#419
This commit is contained in:
Chrisbr 2014-08-28 15:21:05 +02:00
parent 5485fe0e7f
commit 5f8a8ac6d9
63 changed files with 1581 additions and 573 deletions

View file

@ -12,10 +12,6 @@
= u.input :nickname, as: :string
= u.input :affiliation, placeholder: 'Company/User Group/nothing', as: :string
= f.inputs 'Registration Information' do
- if @conference.use_supporter_levels? and @conference.supporter_levels.length > 0
= f.semantic_fields_for :supporter_registration do |reg|
= reg.input :supporter_level, as: :select, collection: @conference.supporter_levels
%span#supporter-link.help-block
- @conference.questions.each do |q|
%h5
= "Q: #{q.title}"
@ -33,10 +29,3 @@
%br
= f.input :social_events, as: :check_boxes, label: false, collection: @conference.social_events
= f.action :submit, button_html: { value: 'Edit Registration', class: 'btn btn-primary' }
:javascript
$("#registration_supporter_registration_attributes_supporter_level_id").change(function () {
var str = "";
#{generate_supporter_level_js @conference}
$("#supporter-link").html(str);
})
.trigger('change');

View file

@ -16,7 +16,6 @@
%th #
%th Name
%th E-Mail
%th Ticket
%th Arrival
%th Departure
%th Attended
@ -32,9 +31,6 @@
= registration.name
%td
= registration.email
%td
- if registration.supporter_level
= registration.supporter_level.title
%td
- if registration.arrival
= registration.arrival.strftime("%d %b %H:%M")

View file

@ -1,10 +0,0 @@
<div class="nested-fields">
<%= f.inputs do %>
<%= f.input :title%>
<%= f.input :url %>
<%= f.input :description, hint: markdown_hint, input_html: { data: { provide: "markdown-editable" } } %>
<%= f.input :ticket_price, hint: 'Please enter price with currency symbol.
For example, $200,₹300' %>
<%= remove_association_link :supporter_level, f %>
<% end %>
</div>

View file

@ -1,7 +0,0 @@
.row
.col-md-8
= semantic_form_for(@conference, :url => admin_conference_supporter_level_path(@conference.short_title, @conference.supporter_levels)) do |f|
= f.input :use_supporter_levels, :label => false
= f.input :include_tickets_in_splash, hint: 'On setting this true you will enable the tickets to be displayed on the splash page'
= dynamic_association :supporter_levels, "Supporter Levels", f
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}

View file

@ -0,0 +1,5 @@
= f.input :title
= f.input :description, input_html: { rows: 5, data: { provide: "markdown-editable" } }
= f.input :price
= f.input :price_currency, as: :select, class: 'form-control', collection: ['USD', 'EUR', 'GBP', 'INR', 'CNY'], include_blank: false
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -0,0 +1,6 @@
%h1
Edit Ticket
.row
.col-md-8
= semantic_form_for(@ticket, :url => admin_conference_ticket_path(@conference.short_title, @ticket)) do |f|
= render partial: 'form', locals: { f: f }

View file

@ -0,0 +1,38 @@
%h1 Tickets
%p.lead
If you add Tickets to your Conference, people will be redirected after registration to a page where they can purchase tickets.
- if @conference.tickets.any?
.row
.col-md-12
%table.table
%thead
%th #
%th Title
%th Price
%th Buyer
%th Show
%th Edit
%th Delete
%tbody
- @conference.tickets.each_with_index do |ticket, index|
%tr
%td
= index + 1
%td
= ticket.title
%td
= humanized_money_with_symbol ticket.price
%td
= ticket.buyers.count
%td
= link_to 'Show', admin_conference_ticket_path(@conference.short_title, ticket.id),
method: :get, class: 'btn btn-success'
%td
= link_to 'Edit', edit_admin_conference_ticket_path(@conference.short_title, ticket.id),
method: :get, class: 'btn btn-primary'
%td
= link_to 'Delete', admin_conference_ticket_path(@conference.short_title, ticket.id),
method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the Ticket for #{ticket.title}?" }
= link_to 'Add Ticket', new_admin_conference_ticket_path, class: 'btn btn-success'

View file

@ -0,0 +1,6 @@
%h1
New Ticket
.row
.col-md-8
= semantic_form_for(@ticket, :url => admin_conference_tickets_path(@conference.short_title, @ticket)) do |f|
= render partial: 'form', locals: { f: f }

View file

@ -0,0 +1,33 @@
%h1
= @ticket.title
%small
= humanized_money_with_symbol @ticket.price
- if @ticket.description.present?
%p.lead
= markdown(@ticket.description)
%h4 The following persons bought this ticket:
%table.table#buyers-datatable
%thead
%th #
%th Name
%th E-Mail
%th Affiliation
%th Paid
%tbody
- @ticket.buyers.each_with_index do |buyer, index|
%tr
%td
= index + 1
%td
= buyer.name
%span.label.label-success
= buyer.ticket_purchases.find_by(ticket_id: @ticket.id).quantity
%td
= buyer.email
%td
= buyer.affiliation
%td
= @ticket.paid?(buyer)
= link_to 'Edit', edit_admin_conference_ticket_path(@conference.short_title, @ticket.id),
method: :get, class: 'btn btn-primary'

View file

@ -17,6 +17,6 @@
= link_to "Modify Registration for #{@conference.short_title}", edit_conference_conference_registrations_path(@conference.short_title), class: "btn btn-success btn-lg", target: '_blank'
- else
= link_to "Register for #{@conference.short_title}", new_conference_conference_registrations_path(@conference.short_title), class: "btn btn-success btn-lg", target: '_blank'
- if @conference.use_supporter_levels?
- if @conference.tickets.any?
- if @conference.include_tickets_in_splash?
= render 'tickets'

View file

@ -1,16 +1,15 @@
%div.row
%h3 Tickets
-if !@conference.ticket_description.blank?
-if @conference.ticket_description.present?
.lead
= markdown(@conference.ticket_description)
- @conference.supporter_levels.each do |s|
- @conference.tickets.each do |ticket|
%div.col-md-6
- if !s.title.blank?
%h4 #{ s.title }
-if !s.description.blank?
.lead #{ s.description }
- if !s.url.blank?
%div.btn-group
= link_to "Buy Ticket", s.url, class: 'btn btn-success', target: '_blank'
- if !s.ticket_price.blank?
= button_tag "#{s.ticket_price}", class: 'btn btn-success'
- if ticket.title.present?
%h4 #{ ticket.title }
- if ticket.description.present?
.lead
= markdown(ticket.description)
%div.btn-group
= link_to "Buy Ticket", conference_tickets_path(@conference.short_title), class: 'btn btn-success'
= button_tag "#{humanized_money_with_symbol ticket.price}", class: 'btn btn-success'

View file

@ -14,22 +14,11 @@
- if @conference.questions
= render partial: 'questions', locals: { f: f }
%br
- if @conference.use_supporter_levels? && @conference.supporter_levels.length > 0
= f.semantic_fields_for :supporter_registration do |reg|
= reg.input :supporter_level, as: :select, collection: @conference.supporter_levels
%span#supporter-link.help-block
- if @workshops.count > 0
- if @conference.events.workshops.any?
=f.inputs 'Register to Workshops' do
= f.input :events, as: :check_boxes, label: false, collection: @workshops
= f.input :events, as: :check_boxes, label: false, collection: @conference.events.workshops
= f.inputs 'Travel Info' do
= f.input :arrival, as: :string, input_html: { value: (f.object.arrival.to_formatted_s(:db_without_seconds) unless f.object.arrival.nil?), id: 'registration-arrival-datepicker', readonly: 'readonly' }
= f.input :departure, as: :string, input_html: { value: (f.object.departure.to_formatted_s(:db_without_seconds) unless f.object.departure.nil?), id: 'registration-departure-datepicker', readonly: 'readonly' }
:javascript
$("#registration_supporter_registration_attributes_supporter_level_id").change(function () {
var str = "";
#{generate_supporter_level_js @conference}
$("#supporter-link").html(str);
}).trigger('change');

View file

@ -0,0 +1,21 @@
%tr
%td.col-sm-8.col-md-6
.media
.media-body
%h4.media-heading
= ticket.title
%h5.media-heading
-if !ticket.description.blank?
= markdown(ticket.description)
%td.col-sm-1.col-md-1
= 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
= ticket.price.symbol
%span{id: "price_#{ticket.id}"}
= humanized_money ticket.price
%td.col-sm-1.col-md-1.text-center
%strong
= ticket.price.symbol
%span.total_row{id: "total_row_#{ticket.id}"}
0

View file

@ -0,0 +1,26 @@
= form_tag(conference_ticket_purchases_path, method: :post) do |f|
%table.table.table-hover
%thead
%tr
%th Ticket
%th Quantity
%th Price
%th Total
%tbody
- tickets.each do |ticket|
= render partial: 'ticket', f: f, locals: { ticket: ticket }
%tr
%td
%td
%td.col-sm-1.col-md-1.text-center
%h4
Total
%td.col-sm-1.col-md-1.text-center
%h4
%strong
%span{ id: 'total_price' }
0
%p
= button_tag(type: 'submit', class: 'btn btn-success btn-lg pull-right') do
Support
%i.fa.fa-shopping-cart

View file

@ -0,0 +1,46 @@
%table.table.table-hover
%thead
%tr
%th Ticket
%th.text-center Quantity
%th.text-center Price
%th.text-center Total
%th
%tbody
- tickets.each do |ticket|
%tr
%td.col-sm-8.col-md-6
.media
.media-body
%h4.media-heading
= ticket.title
%h5.media-heading
-if !ticket.description.blank?
= markdown(ticket.description)
%td.col-sm-1.col-md-1.text-center
= ticket.quantity_bought_by(current_user)
%td.col-sm-1.col-md-1.text-center
= humanized_money_with_symbol ticket.price
%td.col-sm-1.col-md-1.text-center
%strong
= ticket.total_price(current_user)
%td.col-sm-1.col-md-1.text-center
= link_to conference_ticket_purchase_path(@conference.short_title, ticket.id),
method: :delete, class: 'btn btn-danger',
data: { confirm: "Do you really want to delete the #{ticket.title} for #{@conference.title}?" } do
Delete
%i.fa.fa-trash-o
%tr
%td
%td
%td
%td.col-sm-1.col-md-1.text-center
%h4
Total
%td.col-sm-1.col-md-1.text-center
%h4
%strong
- if @total_price.cents == -1
not-calculable
- else
= humanized_money_with_symbol Ticket.total_price(@conference, current_user)

View file

@ -0,0 +1,126 @@
%h1
= @conference.title
%small
= date_string(@conference.start_date, @conference.end_date)
- if @conference.venue.name and @conference.venue.website and @conference.venue.address
%p
%small
at
= link_to @conference.venue.name, @conference.venue.website
,
\#{link_to @conference.venue.address, "http://maps.google.com/maps?q=#{@conference.venue.address}"}
.row
.col-md-4
.row
- if @conference.contact.facebook.present?
%div.col-md-3
= link_to "#{ @conference.contact.facebook }" do
%i.fa.fa-facebook-square.fa-2x
- if @conference.contact.twitter.present?
%div.col-md-3
= link_to "#{ @conference.contact.twitter }" do
%i.fa.fa-twitter.fa-2x
- if @conference.contact.instagram.present?
%div.col-md-3
= link_to "#{ @conference.contact.instagram }" do
%i.fa.fa-instagram.fa-2x
- if @conference.contact.googleplus.present?
%div.col-md-3
= link_to "#{ @conference.contact.googleplus }" do
%i.fa.fa-google-plus-square.fa-2x
%br
- if @conference.tickets.any?
%h3
Tickets
- if current_user.tickets.any?
%p
You have already purchased the following tickets:
%p
If you would like to buy more tickets, please click
= link_to 'here', conference_tickets_path(@conference.short_title)
= render partial: 'tickets_bought', locals: { tickets: current_user.tickets }
- else
= render partial: 'tickets', locals: { tickets: @conference.tickets }
%br
- if @conference.speakers.confirmed.any?
%h3
= pluralize(@conference.speakers.confirmed.count, 'Speaker')
- @conference.speakers.confirmed.limit(12).each_slice(4) do |slice|
.row
- slice.each do |speaker|
.col-md-3
.row
.col-md-3
= image_tag(speaker.gravatar_url(size: '25'),
title: "Yo #{speaker.name}!",
alt: '', 'class' => 'img-circle img-responsive text-center')
.col-md-9
%h4
= speaker.name
%hr
- if @conference.events.confirmed.any?
%h3
= pluralize(@conference.events.confirmed.count, 'Event')
%ul.list-unstyled
- @conference.events.confirmed.limit(10).each do |event|
%li
%h4
= link_to event.title, conference_proposal_path(@conference.short_title, event.id)
%strong
presented by
= event.speaker_names
%hr
- if @conference.participants.any?
%h3
= pluralize(@conference.participants.count, 'Participant')
- @conference.participants.limit(36).each_slice(12) do |slice|
.row
- slice.each do |participant|
.col-md-1
= image_tag(participant.gravatar_url(size: '25'),
title: "Yo #{participant.name}!",
alt: '', 'class' => 'img-circle img-responsive text-center')
%hr
- if @registration
%h2
Congratulations! You are now registered for
= "#{@conference.title}!"
- if @conference.questions.any?
%h3 Your answers to the registrations questions are:
- @conference.questions.each do |q|
%p
%b Question:
= q.title
%b Your Answer:
- @registration.qanswers.where(:question_id => q.id).each do |qa|
= qa.answer.title
%br
- if @workshops.any?
%h3 You are registered for the following workshops:
%ul.list-unstyled
- @workshops.each do |workshop|
%li
%h4
= link_to workshop.title, conference_proposal_path(@conference.short_title, workshop.id)
%strong
presented by
= workshop.speaker_names
%br
%div
= link_to 'Modify your Registration', edit_conference_conference_registrations_path(@conference.short_title), class: 'btn btn-success'
= link_to 'Unregister', conference_conference_registrations_path(@conference.short_title),
method: :delete, class: 'btn btn-danger', confirm: 'Are you sure you want to unregister?'
- else
%p.lead
= "Unfortunately you are not registered for #{@conference.title}. If you want to register click"
= link_to 'here.', new_conference_conference_registrations_path(@conference.short_title)

View file

@ -39,3 +39,5 @@
= link_to "View My Proposals", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
- elsif conference.cfp_open?
= link_to "Submit Proposal", conference_proposal_index_path(conference.short_title), :class =>"btn btn-default"
- if !current_user.nil? && conference.tickets.any?
= link_to 'Support', conference_tickets_path(conference.short_title), class: 'btn btn-default'

View file

@ -102,11 +102,11 @@
- if can? :update, @conference.sponsors.build
%li{:class=> active_nav_li(admin_conference_sponsors_path(@conference.short_title))}
= link_to 'Sponsors', admin_conference_sponsors_path(@conference.short_title)
- if can? :update, @conference.supporter_levels.build
%li{ class: active_nav_li(admin_conference_supporter_levels_path(@conference.short_title)) }
= link_to(admin_conference_supporter_levels_path(@conference.short_title)) do
- if can? :update, @conference.tickets.build
%li{ class: active_nav_li(admin_conference_tickets_path(@conference.short_title)) }
= link_to(admin_conference_tickets_path(@conference.short_title)) do
%span.fa.fa-usd
Supporter Levels
Tickets
- if can? :update, @conference.email_settings
%li{:class=> active_nav_li(admin_conference_emails_path(@conference.short_title))}
= link_to(admin_conference_emails_path(@conference.short_title)) do

View file

@ -0,0 +1,25 @@
%tr
%td.col-sm-8.col-md-6
.media
.media-body
%h4.media-heading
= ticket.title
%h5.media-heading
-if !ticket.description.blank?
= markdown(ticket.description)
%td.col-sm-1.col-md-1
- if ticket.bought?(current_user)
= text_field_tag("tickets[][#{ticket.id}]", ticket.quantity_bought_by(current_user),
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
= ticket.price.symbol
%span{id: "price_#{ticket.id}"}
= humanized_money ticket.price
%td.col-sm-1.col-md-1.text-center
%strong
= ticket.price.symbol
%span.total_row{id: "total_row_#{ticket.id}"}
0

View file

@ -0,0 +1,37 @@
.row
.col-sm-12.col-md-10.col-md-offset-1
%h1
Tickets
%p.lead
Please buy a ticket if you want to support
%b
= @conference.title
!
=form_tag(conference_ticket_purchases_path, method: :post) do |f|
%table.table.table-hover
%thead
%tr
%th Ticket
%th Quantity
%th Price
%th Total
%tbody
- @conference.tickets.each do |ticket|
= render partial: 'ticket', f: f, locals: {ticket: ticket}
%tr
%td
%td
%td.col-sm-1.col-md-1.text-center
%h4
Total
%td.col-sm-1.col-md-1.text-center
%h4
%strong
%span{id: 'total_price'}
0
.pull-right
= button_tag(type: 'submit', class: 'btn btn-success btn-lg') do
Support
%i.fa.fa-shopping-cart
= link_to 'Continue without a Ticket!', conference_conference_registrations_path(@conference.short_title),
class: 'btn btn-danger btn-sm'