mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Use a picture format for ticketing
Instead of analyzing image size using the local file, rely on a processed image of the appropriate dimensions. Resolves #1828
This commit is contained in:
parent
e01d849374
commit
710010cb76
3 changed files with 14 additions and 15 deletions
|
|
@ -1,3 +1,5 @@
|
|||
require 'open-uri'
|
||||
|
||||
class TicketPdf < Prawn::Document
|
||||
def initialize(conference, user, physical_ticket, ticket_layout, 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
|
||||
move_up 150
|
||||
if @conference.picture?
|
||||
if 7 * @conference.picture.image[:width] > 12 * @conference.picture.image[:height]
|
||||
image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], width: 120
|
||||
else
|
||||
image "#{Rails.root}/public#{@conference.picture_url}", at: [@mid_horizontal + 30, cursor], height: 70
|
||||
end
|
||||
conference_image = case @conference.picture.ticket.url[0, 4]
|
||||
when 'http', 'ftp:' # CDNs
|
||||
open(@conference.picture.ticket.url)
|
||||
when '/sys' # local storage
|
||||
open([
|
||||
Rails.root,
|
||||
'/public',
|
||||
@conference.picture.ticket.url
|
||||
].join)
|
||||
end
|
||||
image conference_image, at: [@mid_horizontal + 30, cursor]
|
||||
else
|
||||
image "#{Rails.root}/public/img/osem-logo.png", at: [@mid_horizontal + 30, cursor], height: 70
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue