Merge pull request #1834 from bear454/fix-speaker-registration-issues
Fix speaker registration issues
This commit is contained in:
commit
952e8ac316
6 changed files with 37 additions and 16 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
require 'open-uri'
|
||||||
|
|
||||||
class TicketPdf < Prawn::Document
|
class TicketPdf < Prawn::Document
|
||||||
def initialize(conference, user, physical_ticket, ticket_layout, file_name)
|
def initialize(conference, user, physical_ticket, ticket_layout, file_name)
|
||||||
super(page_layout: ticket_layout, page_size: 'A4', filename: file_name)
|
super(page_layout: ticket_layout, page_size: 'A4', filename: file_name)
|
||||||
|
|
@ -43,11 +45,17 @@ class TicketPdf < Prawn::Document
|
||||||
def draw_second_square
|
def draw_second_square
|
||||||
move_up 150
|
move_up 150
|
||||||
if @conference.picture?
|
if @conference.picture?
|
||||||
if 7 * @conference.picture.image[:width] > 12 * @conference.picture.image[:height]
|
conference_image = case @conference.picture.ticket.url[0, 4]
|
||||||
image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], width: 120
|
when 'http', 'ftp:' # CDNs
|
||||||
else
|
open(@conference.picture.ticket.url)
|
||||||
image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], height: 70
|
when '/sys' # local storage
|
||||||
end
|
open([
|
||||||
|
Rails.root,
|
||||||
|
'/public',
|
||||||
|
@conference.picture.ticket.url
|
||||||
|
].join)
|
||||||
|
end
|
||||||
|
image conference_image, at: [@mid_horizontal + 30, cursor]
|
||||||
else
|
else
|
||||||
image "#{Rails.root}/public/img/osem-logo.png", at: [@mid_horizontal + 30, cursor], height: 70
|
image "#{Rails.root}/public/img/osem-logo.png", at: [@mid_horizontal + 30, cursor], height: 70
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,6 @@ class PictureUploader < CarrierWave::Uploader::Base
|
||||||
"system/#{object_class_name}/#{mounted_as}/#{model.id}"
|
"system/#{object_class_name}/#{mounted_as}/#{model.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def image
|
|
||||||
@image ||= MiniMagick::Image.open(file.file)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Create different versions of your uploaded files:
|
# Create different versions of your uploaded files:
|
||||||
version :large do
|
version :large do
|
||||||
process resize_to_fit: [300, 300]
|
process resize_to_fit: [300, 300]
|
||||||
|
|
@ -80,6 +76,11 @@ class PictureUploader < CarrierWave::Uploader::Base
|
||||||
process resize_and_pad: [320, 120, 'white']
|
process resize_and_pad: [320, 120, 'white']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
version :ticket, if: :conference?
|
||||||
|
version :ticket do
|
||||||
|
process resize_and_pad: [120, 70]
|
||||||
|
end
|
||||||
|
|
||||||
# Add a white list of extensions which are allowed to be uploaded.
|
# Add a white list of extensions which are allowed to be uploaded.
|
||||||
# For images you might use something like this:
|
# For images you might use something like this:
|
||||||
def extension_white_list
|
def extension_white_list
|
||||||
|
|
@ -95,4 +96,8 @@ class PictureUploader < CarrierWave::Uploader::Base
|
||||||
def sponsor?(_picture)
|
def sponsor?(_picture)
|
||||||
object_class_name == 'sponsors'
|
object_class_name == 'sponsors'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def conference?(_picture)
|
||||||
|
object_class_name == 'conferences'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,7 @@
|
||||||
= @user.email
|
= @user.email
|
||||||
.col-md-5.col-md-offset-2.box.well
|
.col-md-5.col-md-offset-2.box.well
|
||||||
- if @conference.picture?
|
- if @conference.picture?
|
||||||
- width = @conference.picture.image[:width]
|
= image_tag(@conference.picture.ticket.url, class: 'img-responsive')
|
||||||
- height = @conference.picture.image[:height]
|
|
||||||
- if 10 * width > 15 * height
|
|
||||||
= image_tag(@conference.picture_url, width: '150')
|
|
||||||
- else
|
|
||||||
= image_tag(@conference.picture_url, height: '100')
|
|
||||||
- else
|
- else
|
||||||
= image_tag('/img/osem-logo.png', class: 'img-responsive')
|
= image_tag('/img/osem-logo.png', class: 'img-responsive')
|
||||||
%p.text-left
|
%p.text-left
|
||||||
|
|
|
||||||
9
db/migrate/20171130172334_rebuild_conference_pictures.rb
Normal file
9
db/migrate/20171130172334_rebuild_conference_pictures.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
class RebuildConferencePictures < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
Conference.all.each do |conference|
|
||||||
|
conference.picture.recreate_versions!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down; end
|
||||||
|
end
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20171118113113) do
|
ActiveRecord::Schema.define(version: 20171130172334) do
|
||||||
|
|
||||||
create_table "ahoy_events", force: :cascade do |t|
|
create_table "ahoy_events", force: :cascade do |t|
|
||||||
t.integer "visit_id"
|
t.integer "visit_id"
|
||||||
|
|
|
||||||
|
|
@ -1704,4 +1704,8 @@ describe Conference do
|
||||||
|
|
||||||
it { is_expected.to eq [past_conference1, past_conference2] }
|
it { is_expected.to eq [past_conference1, past_conference2] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should have a picture format for tickets' do
|
||||||
|
expect(create(:conference).picture.ticket.url)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue