Fix issues with attaching QR code to email
This commit is contained in:
parent
b5c88b1f8e
commit
de45091c59
2
Gemfile
2
Gemfile
|
@ -62,6 +62,8 @@ gem "faraday"
|
|||
|
||||
gem "rqrcode"
|
||||
|
||||
gem "draper"
|
||||
|
||||
group :development do
|
||||
gem "spring"
|
||||
gem "spring-commands-rspec"
|
||||
|
|
11
Gemfile.lock
11
Gemfile.lock
|
@ -37,6 +37,10 @@ GEM
|
|||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.3)
|
||||
activesupport (= 5.2.3)
|
||||
activemodel-serializers-xml (1.0.2)
|
||||
activemodel (> 5.x)
|
||||
activesupport (> 5.x)
|
||||
builder (~> 3.1)
|
||||
activerecord (5.2.3)
|
||||
activemodel (= 5.2.3)
|
||||
activesupport (= 5.2.3)
|
||||
|
@ -139,6 +143,12 @@ GEM
|
|||
devise (>= 4.6)
|
||||
diff-lcs (1.3)
|
||||
docile (1.3.2)
|
||||
draper (3.1.0)
|
||||
actionpack (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
activemodel-serializers-xml (>= 1.0)
|
||||
activesupport (>= 5.0)
|
||||
request_store (>= 1.0)
|
||||
erubi (1.9.0)
|
||||
execjs (2.7.0)
|
||||
factory_bot (5.1.1)
|
||||
|
@ -454,6 +464,7 @@ DEPENDENCIES
|
|||
delorean
|
||||
devise
|
||||
devise-i18n
|
||||
draper
|
||||
factory_bot_rails
|
||||
faker
|
||||
faraday
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class Public::EventFeedbackQrcodesController < Public::ApplicationController
|
||||
def show
|
||||
event = current_conference.events.joins(:proposition).approved.find(params[:event_id])
|
||||
event = current_conference.events.joins(:proposition).approved.find(params[:event_id]).decorate
|
||||
|
||||
respond_to do |format|
|
||||
format.svg do
|
||||
render(inline: helpers.feedback_qr_code_as_svg(event.id),
|
||||
render(inline: event.feedback_qr_code_as_svg,
|
||||
filename: "feedback_qr_code_#{event.id}.svg")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
class ApplicationDecorator < Draper::Decorator
|
||||
# Define methods for all decorated objects.
|
||||
# Helpers are accessed through `helpers` (aka `h`). For example:
|
||||
#
|
||||
# def percent_amount
|
||||
# h.number_to_percentage object.amount, precision: 2
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
class EventDecorator < Draper::Decorator
|
||||
delegate_all
|
||||
|
||||
# Define presentation-specific methods here. Helpers are accessed through
|
||||
# `helpers` (aka `h`). You can override attributes, for example:
|
||||
#
|
||||
# def created_at
|
||||
# helpers.content_tag :span, class: 'time' do
|
||||
# object.created_at.strftime("%a %m/%d/%y")
|
||||
# end
|
||||
# end
|
||||
|
||||
def feedback_qr_code
|
||||
RQRCode::QRCode.new(h.new_event_feedback_url(event_id: id), level: :l)
|
||||
end
|
||||
|
||||
def feedback_qr_code_as_svg
|
||||
feedback_qr_code.as_svg(shape_rendering: "crispEdges", module_size: 11, fill: "ffffff", offset: 10)
|
||||
end
|
||||
end
|
|
@ -85,12 +85,4 @@ module ApplicationHelper
|
|||
when 6 then t('ratings.excellent')
|
||||
end
|
||||
end
|
||||
|
||||
def feedback_qr_code(event_id)
|
||||
RQRCode::QRCode.new(new_event_feedback_url(event_id: event_id), level: :l)
|
||||
end
|
||||
|
||||
def feedback_qr_code_as_svg(event_id)
|
||||
feedback_qr_code(event_id).as_svg(shape_rendering: "crispEdges", module_size: 11, fill: "ffffff", offset: 10)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
class EventMailer < ActionMailer::Base
|
||||
helper ApplicationHelper
|
||||
|
||||
def confirmation_request(event)
|
||||
@event = event
|
||||
@event = event.decorate
|
||||
I18n.locale = @event.proposer.language
|
||||
|
||||
attachments['feedback-link-qr-code.svg'] = {
|
||||
mime_type: 'image/svg+xml',
|
||||
content: helpers.feedback_qr_code_as_svg(@event.id)
|
||||
content: @event.feedback_qr_code_as_svg
|
||||
}
|
||||
|
||||
mail to: @event.proposer.email,
|
||||
from: "program@openfest.org",
|
||||
subject: I18n.t("event_mailer.acceptance_notification.subject",
|
||||
|
|
Loading…
Reference in New Issue