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

Incorporate non-standard proposal in pdf workflow #574

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

EdoStorm96
Copy link
Contributor

Fix for issue #572. I got rid of now obsolete pdf templates and made sure the pre-assessment and pre-approval proposals are properly incorporated in the new PDF workflow.

Maybe the pdf_template_name function can be removed entirely? I guess it is not being used in this version. What do y'all think?

@tymees I did notice that the change to https in the handle_field_file function of the RowValueClass causes an error in my browser when clicking links in the pdf, with the error code: SSL_ERROR_RX_RECORD_TOO_LONG

However, Django tells me this is because the development server only support http:

You're accessing the development server over HTTPS, but it only supports HTTP.

So it will be fine on the production server?

@EdoStorm96 EdoStorm96 requested review from tymees and miggol November 9, 2023 15:44
@EdoStorm96 EdoStorm96 linked an issue Nov 9, 2023 that may be closed by this pull request
@tymees
Copy link
Member

tymees commented Nov 9, 2023

@tymees I did notice that the change to https in the handle_field_file function of the RowValueClass causes an error in my browser when clicking links in the pdf, with the error code: SSL_ERROR_RX_RECORD_TOO_LONG

However, Django tells me this is because the development server only support http:

You're accessing the development server over HTTPS, but it only supports HTTP.

So it will be fine on the production server?

I'll look at this PR tomorrow in-depth. But for now:

Yeah, it's because local dev doesn't have https. Normally, you'd solve this by retrieving the used protocol (http vs https) from the request object; but PDF gen doesn't (always) have access to that.

It will be fine on the server, those are HTTPS only. You could maybe create an if on the DEBUG setting, but I don't have any strong opinions tbh

Comment on lines 704 to 706
@property
def pdf_template_name(self):
"""Determine the correct PDf template for this proposal."""
template_name = 'proposals/proposal_pdf.html'
if self.is_pre_approved:
template_name = 'proposals/proposal_pdf_pre_approved.html'
elif self.is_pre_assessment:
template_name = 'proposals/proposal_pdf_pre_assessment.html'
return template_name
return 'proposals/proposal_pdf.html'
Copy link
Member

Choose a reason for hiding this comment

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

I agree that this is redundant now; differences should be handled by the new PDF framework

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 got rid of this now, and its reference in the ProposalAsPDF view. This works fine for me. I was wondering does this now require a migration?

Copy link
Member

Choose a reason for hiding this comment

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

No it doesn't. Migrations are only needed for ORM Fields (which are always class variables, and (almost) always named xField). This is a class method, those should never trigger migrations.

If you are unsure, you can run python manage.py makemigrations --dry-run. This will only display the migrations Django wants to create, without actually creating them.

Alternatively, we now have a check for PR's that will tell you if you are missing a migration. The latest run passed successfully: https://github.com/DH-IT-Portal-Development/ethics/actions/runs/6847879373/job/18616976001?pr=574

@EdoStorm96 EdoStorm96 merged commit 26991b0 into develop Nov 13, 2023
2 checks passed
@EdoStorm96 EdoStorm96 deleted the fix/wrong_pdf_template_bug branch November 21, 2023 14:57
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.

Non-standard proposals using the wrong PDF template
2 participants