Permalink
Browse files

generate PDFs inline

  • Loading branch information...
1 parent fd2e990 commit 0543e839a2118208754535011cc710d09de1c9cc Alex Mekelburg committed Oct 19, 2013
Showing with 33 additions and 17 deletions.
  1. +19 −14 app/models/registrant.rb
  2. +12 −2 config/deploy.rb
  3. +1 −1 lib/pdf_renderer.rb
  4. +1 −0 pdfs/.gitignore
@@ -825,13 +825,7 @@ def form_date_of_birth
end
def wrap_up
- if RockyConf.delayed_wrap_up
- action = Delayed::PerformableMethod.new(self, :complete!, [])
- Delayed::Job.enqueue(action, {:priority=>WRAP_UP_PRIORITY, :run_at=>Time.now})
- else
- complete
- save!
- end
+ complete!
end
def complete_registration
@@ -844,8 +838,7 @@ def complete_registration
# Enqueues final registration actions for API calls
def enqueue_complete_registration_via_api
- action = Delayed::PerformableMethod.new(self, :complete_registration_via_api, [])
- Delayed::Job.enqueue(action, {:priority=>WRAP_UP_PRIORITY, :run_at=>Time.now})
+ self.complete_registration_via_api
end
# Called from the worker queue to generate PDFs on the 'util' server
@@ -980,13 +973,25 @@ def nvra_template_path
File.join(Rails.root, "data", "nvra_templates", "nvra_#{locale && locale.downcase}_#{home_state && home_state.abbreviation.downcase}.pdf")
end
- def pdf_path
- "/pdf/#{bucket_code}/#{to_param}.pdf"
+ def pdf_path(pdfpre = nil)
+ "/#{pdf_dir(pdfpre)}/#{to_param}.pdf"
+ end
+
+ def pdf_dir(pdfpre = nil)
+ if pdfpre
+ "#{pdfpre}/#{bucket_code}"
+ else
+ if File.exists?(pdf_file_path("pdf"))
+ "pdf/#{bucket_code}"
+ else
+ "pdfs/#{bucket_code}"
+ end
+ end
end
- def pdf_file_path
- FileUtils.mkdir_p(File.join(Rails.root, "pdf", bucket_code))
- File.join(Rails.root, pdf_path)
+ def pdf_file_path(pdfpre = nil)
+ FileUtils.mkdir_p(File.join(Rails.root, pdf_dir(pdfpre)))
+ File.join(Rails.root, pdf_path(pdfpre))
end
def bucket_code
View
@@ -88,7 +88,7 @@
-after "deploy:update_code", "deploy:symlink_configs", "deploy:symlink_pdf", "deploy:symlink_csv", "deploy:symlink_partners", "deploy:migrate"
+after "deploy:update_code", "deploy:symlink_configs", "deploy:symlink_util_pdf", "deploy:symlink_web_pdf", "deploy:symlink_csv", "deploy:symlink_partners", "deploy:migrate"
set :rake, 'bundle exec rake'
@@ -166,14 +166,24 @@
end
+ desc "Link the pdf dir to shared/pdfs"
+ task :symlink_web_pdf, :roles => [:web], :except => {:no_release => true} do
+ run <<-CMD
+ mkdir -p #{shared_path}/pdfs &&
+ cd #{latest_release} &&
+ ln -nfs #{shared_path}/pdfs #{latest_release}/public/pdfs
+ CMD
+ end
+
desc "Link the pdf dir to /data/rocky/pdf"
- task :symlink_pdf, :roles => [:util], :except => {:no_release => true} do
+ task :symlink_util_pdf, :roles => [:util], :except => {:no_release => true} do
run <<-CMD
cd #{latest_release} &&
rm -rf pdf &&
ln -nfs #{ENV['SYMLINK_DATA_DIR']}/html pdf
CMD
end
+
desc "Link the csv dir to /data/rocky/csv"
task :symlink_csv, :roles => [:util], :except => {:no_release => true} do
View
@@ -26,7 +26,7 @@ def initialize(registrant)
def logo_image_path
if @registrant.partner && @registrant.partner.whitelabeled? && @registrant.partner.pdf_logo_present?
- "http://#{RockyConf.pdf_host_name}#{@registrant.partner.pdf_logo_url}"
+ @registrant.partner.absolute_pdf_logo_path
else
"file:///#{Rails.root.join('app/assets/images', RockyConf.pdf.nvra.page1.default_logo).to_s}"
end
View
@@ -0,0 +1 @@
+*.pdf

0 comments on commit 0543e83

Please sign in to comment.