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

Add Optional Signature Lines to Distribution PDF #4342

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

sean-dickinson
Copy link
Contributor

Resolves #4312

Description

Some organizations want to include signature fields on their distribution pdf printouts. We want to make this optional for organizations to toggle this setting on or off on their own so they don't have to use comments as a work around.

  • Adds a new boolean database field to organizations to add the option to show signature lines on their distribution pdfs (default is false)
  • Updates the organization show/edit views to include this new field
  • Updates the distribution pdf to append the signature lines based on the value of this flag

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • I've tested this locally manually by ensuring that I can enable/disable this setting on the organization edit page and that the change is reflected on the pdf
  • I've updated the organization request specs in 2 important ways
    • I've removed the double for the pdf so it actually renders
    • I've added a new case for the print endpoint to ensure it is still successful when the flag is set to true

Screenshots

Organization show view
localhost_3000_diaper_bank_organization(HiDPI Laptop)
Organization edit view
localhost_3000_diaper_bank_manage_edit(HiDPI Laptop)

PDF with Signature fields included
Screenshot 2024-05-07 at 8 03 09 PM

@@ -14,7 +14,6 @@
let(:hashed_id) { CGI.escape(crypt.encrypt_and_sign(organization.id)) }
before(:each) do
allow(Rails.application).to receive(:secret_key_base).and_return(secret_key)
allow(DistributionPdf).to receive(:new).and_return(double("DistributionPdf", compute_and_render: "PDF"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was being mocked to save time/resources? Locally I'm not seeing a significant difference in how long this test file takes to run with or without it. I think it might make more sense to add this mocking to the contexts that actually need the mock rather than just doing it at the top level here? But then again I'm trying to prove that my new feature doesn't cause the pdf to blow up and the only way to do that is to actually render it, but maybe that's less important? Happy to revert this if that makes more sense.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If everything works and it doesn't slow it down noticeably, it's fine to unstub it.

@@ -0,0 +1,11 @@
class AddSignatureFieldsFlagToOrganizations < ActiveRecord::Migration[7.0]
def up
add_column :organizations, :include_signature_fields_on_distribution_printout, :boolean
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a bit less wordy? Maybe signature_for_distribution_pdf?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely, naming things is always a pain so I tend to default to extra verbose

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone ahead and made this change.

@@ -14,7 +14,6 @@
let(:hashed_id) { CGI.escape(crypt.encrypt_and_sign(organization.id)) }
before(:each) do
allow(Rails.application).to receive(:secret_key_base).and_return(secret_key)
allow(DistributionPdf).to receive(:new).and_return(double("DistributionPdf", compute_and_render: "PDF"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If everything works and it doesn't slow it down noticeably, it's fine to unstub it.

@sean-dickinson sean-dickinson force-pushed the 4312-add-optional-signature-line branch from 2bf7c68 to 338e344 Compare May 10, 2024 17:01
Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @cielf did you want to check it over?

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual functionality works like a dream.

I'm afraid I have a wee nit-pick though: Can we please refer to them as "signature lines" instead of "signature fields" throughout? Calling them fields implies that it's something they can fill in on-line.

Thank you

@sean-dickinson sean-dickinson force-pushed the 4312-add-optional-signature-line branch from 35f44e8 to ee10266 Compare May 13, 2024 12:17
@sean-dickinson sean-dickinson requested a review from cielf May 13, 2024 12:23
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alas I spoke too soon -- I didnt initially test the border case where the signatures could potentially span pages. They shouldn't, though.
Sample Distribution pdf.pdf

@sean-dickinson
Copy link
Contributor Author

Alas I spoke too soon -- I didnt initially test the border case where the signatures could potentially span pages. They shouldn't, though. Sample Distribution pdf.pdf

Ah that makes sense. I'll dig into prawn to see if there's a way to ensure this doesn't happen.

@sean-dickinson
Copy link
Contributor Author

@cielf I've gone ahead and addressed the edge case. Here's the results:

Before:
Screenshot 2024-05-13 at 1 48 48 PM

After:
Screenshot 2024-05-13 at 1 52 37 PM

@sean-dickinson sean-dickinson requested a review from cielf May 13, 2024 17:57
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nearly there, but it would be good if the signature lines cleared the "Lovingly created" at the bottom in all cases.
Pawnee Pregnancy Center 2024-05-08.pdf
The failing tests are unrelated. I'm pretty sure they've been fixed on main.

@sean-dickinson
Copy link
Contributor Author

sean-dickinson commented May 30, 2024

Very nearly there, but it would be good if the signature lines cleared the "Lovingly created" at the bottom in all cases. Pawnee Pregnancy Center 2024-05-08.pdf The failing tests are unrelated. I'm pretty sure they've been fixed on main.

@cielf This should be ready to test again, I've adjusted the margin so it now accounts for the footer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add optional signature line to distribution printout
3 participants