mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
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:
parent
e25de318bd
commit
dd52a9b2ab
10 changed files with 38 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
#
|
||||
|
|
|
|||
|
|
@ -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' }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
class AddTicketLayoutToConferences < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :conferences, :ticket_layout, :integer, default: 0
|
||||
end
|
||||
end
|
||||
|
|
@ -105,6 +105,7 @@ ActiveRecord::Schema.define(version: 20170629162450) do
|
|||
t.integer "start_hour", default: 9
|
||||
t.integer "end_hour", default: 20
|
||||
t.integer "organization_id"
|
||||
t.integer "ticket_layout", default: 0
|
||||
end
|
||||
|
||||
add_index "conferences", ["organization_id"], name: "index_conferences_on_organization_id"
|
||||
|
|
|
|||
20
spec/controllers/physical_ticket_controller_spec.rb
Normal file
20
spec/controllers/physical_ticket_controller_spec.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PhysicalTicketController do
|
||||
let(:conference) { create(:conference) }
|
||||
let(:user) { create(:user) }
|
||||
let(:paid_ticket_purchase) { create(:ticket_purchase, conference: conference, user: user) }
|
||||
let(:physical_ticket) { create(:physical_ticket, ticket_purchase: paid_ticket_purchase) }
|
||||
|
||||
describe 'GET #show' do
|
||||
before :each do
|
||||
sign_in user
|
||||
get :show, id: physical_ticket.id, conference_id: conference.short_title
|
||||
end
|
||||
|
||||
it 'assigns ticket_layout' do
|
||||
ticket_layout = conference.ticket_layout.to_sym
|
||||
expect(assigns(:ticket_layout)).to eq ticket_layout
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -10,6 +10,7 @@ FactoryGirl.define do
|
|||
start_hour 9
|
||||
end_hour 20
|
||||
registration_limit 0
|
||||
ticket_layout 'portrait'
|
||||
description { Faker::Hipster.paragraph }
|
||||
organization
|
||||
after(:create) do |conference|
|
||||
|
|
|
|||
|
|
@ -1573,6 +1573,10 @@ describe Conference do
|
|||
should validate_presence_of(:end_hour)
|
||||
end
|
||||
|
||||
it 'is not valid without a ticket_layout' do
|
||||
should validate_presence_of(:ticket_layout)
|
||||
end
|
||||
|
||||
it 'is not valid with a duplicate short title' do
|
||||
should validate_uniqueness_of(:short_title)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue