Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate pdf also when inactive #90

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/reports/questionnaire_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def to_pdf requester, user, questionnaire, url_prefix, short_version=false
ap_logo = ap && ap.logo && ap.logo.path
fallback_logo = Dir.glob("public/assets/logos/#{current_instance.split('-').first}*", File::FNM_CASEFOLD).first
logo = ap_logo || "#{Rails.root}/#{fallback_logo}"
image logo, position: :right, width: 150 if logo
image logo, position: :right, width: 150 if logo && File.exist?(logo)
text "#{current_instance.upcase}", size: 14, style: :bold

move_down 10
Expand Down
4 changes: 1 addition & 3 deletions app/workers/pdf_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ def perform(requester_id, user_id, questionnaire_id, url_prefix, short_version)
user = User.find(user_id)
questionnaire = Questionnaire.find(questionnaire_id)
requester = requester_id == user_id ? user : User.find(requester_id)
if requester.role?(:admin) || questionnaire.status != QuestionnaireStatus::INACTIVE
QuestionnairePdf.new.to_pdf requester, user, questionnaire, url_prefix, short_version
end
QuestionnairePdf.new.to_pdf requester, user, questionnaire, url_prefix, short_version
rescue => e
Appsignal.add_exception(e)
end
Expand Down