Make ticket layout configurable

Added option for conference organizer to switch between ticket layouts (horizontal or vertical). Added test for the same.
This commit is contained in:
siddhantbajaj 2017-06-30 05:26:21 +05:30
parent e25de318bd
commit dd52a9b2ab
10 changed files with 38 additions and 2 deletions

View file

@ -211,7 +211,7 @@ module Admin
:vpositions_attributes, :use_volunteers, :color,
:sponsorship_levels_attributes, :sponsors_attributes,
:targets, :targets_attributes,
:campaigns, :campaigns_attributes, :registration_limit, :organization_id)
:campaigns, :campaigns_attributes, :registration_limit, :organization_id, :ticket_layout)
end
end
end

View file

@ -12,5 +12,6 @@ class PhysicalTicketController < ApplicationController
def show
@file_name = "ticket_for_#{@conference.short_title}"
@user = @physical_ticket.user
@ticket_layout = @conference.ticket_layout.to_sym
end
end

View file

@ -57,6 +57,7 @@ class Conference < ActiveRecord::Base
:end_date,
:start_hour,
:end_hour,
:ticket_layout,
:organization, presence: true
validates :short_title, uniqueness: true
@ -73,6 +74,8 @@ class Conference < ActiveRecord::Base
after_create :create_free_ticket
after_update :delete_event_schedules
enum ticket_layout: [:portrait, :landscape]
##
# Checks if the user is registered to the conference
#

View file

@ -17,6 +17,7 @@
= image_tag @conference.picture.thumb.url
= f.input :picture, label: false, hint: 'This will be displayed on the front page.'
= f.hidden_field :picture_cache
= f.input :ticket_layout, as: :select, collection: Conference.ticket_layouts.keys, hint: "Layout type for tickets of the conference."
= f.inputs name: 'Scheduling' do
= f.input :timezone, as: :time_zone, hint: 'The conference time zone'
= f.input :start_date, as: :string, input_html: { id: 'conference-start-datepicker', readonly: 'readonly' }

View file

@ -1,4 +1,4 @@
prawn_document(filename: @file_name, page_layout: :portrait, :page_size =>'A4' ) do |pdf|
prawn_document(filename: @file_name, page_layout: @ticket_layout, :page_size =>'A4' ) do |pdf|
# Vertical Layout
top = pdf.bounds.top
bottom = pdf.bounds.bottom