Skip to content

Commit

Permalink
Migrate initiative signatures to HexaPDF (decidim#13691)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecslupu authored Dec 3, 2024
1 parent bc73358 commit c2cf4cb
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 407 deletions.
7 changes: 7 additions & 0 deletions decidim-core/lib/decidim/exporters/pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module Exporters
# the desired template, layout and orientation.
#
class PDF < Exporter
include Decidim::TranslatableAttributes
include Decidim::SanitizeHelper

# Public: Exports a PDF version of the collection by rendering
# the template into html and then converting it to PDF.
#
Expand Down Expand Up @@ -43,6 +46,10 @@ def composer
@composer ||= ::HexaPDF::Composer.new
end

def page_size = :A4

def page_orientation = :portrait

def add_data!
raise NotImplementedError
end
Expand Down
3 changes: 0 additions & 3 deletions decidim-forms/lib/decidim/exporters/form_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ module Exporters
#
class FormPDF < PDF
# i18n-tasks-use t('decidim.admin.exports.formats.FormPDF')

include Decidim::TranslatableAttributes
include Decidim::SanitizeHelper
include ActionView::Helpers::NumberHelper
include Decidim::Forms::Admin::QuestionnaireAnswersHelper

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,14 @@ def export_pdf_signatures

@votes = current_initiative.votes

output = render_to_string(
pdf: "votes_#{current_initiative.id}",
layout: "decidim/admin/initiatives_votes",
template: "decidim/initiatives/admin/initiatives/export_pdf_signatures",
format: [:pdf]
)
output = pdf_signature_service.new(pdf: output).signed_pdf if pdf_signature_service
serializer = Decidim::Forms::UserAnswersSerializer
output = Decidim::Exporters::InitiativeVotesPDF.new(@votes, current_initiative, serializer).export
output = pdf_signature_service.new(pdf: output.read).signed_pdf if pdf_signature_service

respond_to do |format|
format.pdf do
send_data(output, filename: "votes_#{current_initiative.id}.pdf", type: "application/pdf")
end
format.html
end
end

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def signed_pdf
private

def signature_widget(doc)
doc.pages.add.document

form = doc.acro_form(create: true)
form.signature_flag(:append_only)

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 1 addition & 2 deletions decidim-initiatives/config/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
Decidim::Webpacker.register_path("#{base_path}/app/packs")
Decidim::Webpacker.register_entrypoints(
decidim_initiatives: "#{base_path}/app/packs/entrypoints/decidim_initiatives.js",
decidim_initiatives_admin: "#{base_path}/app/packs/entrypoints/decidim_initiatives_admin.js",
decidim_initiatives_initiatives_votes: "#{base_path}/app/packs/entrypoints/decidim_initiatives_initiatives_votes.js"
decidim_initiatives_admin: "#{base_path}/app/packs/entrypoints/decidim_initiatives_admin.js"
)
Loading

0 comments on commit c2cf4cb

Please sign in to comment.