mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
Make the letter-validation-preview url public.
In the short term I have created a duplicate version of the letter-validation-preview so that people from a service can upload a pdf and see why the letter isnot validating. It's hard to get a precompiled letter to validate when starting to integrate with Notify. This will return the overlay of the letter validation and is now available to the services. At the moment they send us a PDF to upload. This is temporary because there is a story to create a one-off flow to get this overlay, that will replace this page. There is no navigation to this on purpose.
This commit is contained in:
@@ -253,16 +253,29 @@ def platform_admin_returned_letters():
|
||||
@login_required
|
||||
@user_is_platform_admin
|
||||
def platform_admin_letter_validation_preview():
|
||||
return letter_validation_preview(from_platform_admin=True)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/letter-validation-preview", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def service_letter_validation_preview(service_id):
|
||||
return letter_validation_preview(from_platform_admin=False)
|
||||
|
||||
|
||||
def letter_validation_preview(from_platform_admin):
|
||||
message, pages, result = None, [], None
|
||||
form = PDFUploadForm()
|
||||
|
||||
view_location = 'views/platform-admin/letter-validation-preview.html' \
|
||||
if from_platform_admin else'views/letter-validation-preview.html'
|
||||
|
||||
if form.validate_on_submit():
|
||||
pdf_file = form.file.data
|
||||
virus_free = antivirus_client.scan(pdf_file)
|
||||
|
||||
if not virus_free:
|
||||
return render_template(
|
||||
'views/platform-admin/letter-validation-preview.html',
|
||||
view_location,
|
||||
form=form, message="Document didn't pass the virus scan", pages=pages, result=result
|
||||
), 400
|
||||
|
||||
@@ -275,14 +288,14 @@ def platform_admin_letter_validation_preview():
|
||||
if error.response and error.response.status_code == 400:
|
||||
message = "Something was wrong with the file you tried to upload. Please upload a valid PDF file."
|
||||
return render_template(
|
||||
'views/platform-admin/letter-validation-preview.html',
|
||||
view_location,
|
||||
form=form, message=message, pages=pages, result=result
|
||||
), 400
|
||||
else:
|
||||
raise error
|
||||
|
||||
return render_template(
|
||||
'views/platform-admin/letter-validation-preview.html',
|
||||
view_location,
|
||||
form=form, message=message, pages=pages, result=result
|
||||
)
|
||||
|
||||
|
||||
@@ -233,6 +233,7 @@ class HeaderNavigation(Navigation):
|
||||
'service_edit_sms_sender',
|
||||
'service_email_reply_to',
|
||||
'service_letter_contact_details',
|
||||
'service_letter_validation_preview',
|
||||
'service_name_change',
|
||||
'service_name_change_confirm',
|
||||
'service_preview_email_branding',
|
||||
@@ -487,6 +488,7 @@ class MainNavigation(Navigation):
|
||||
'service_dashboard_updates',
|
||||
'service_delete_email_reply_to',
|
||||
'service_delete_sms_sender',
|
||||
'service_letter_validation_preview',
|
||||
'service_switch_can_upload_document',
|
||||
'service_switch_live',
|
||||
'service_set_permission',
|
||||
@@ -701,6 +703,7 @@ class CaseworkNavigation(Navigation):
|
||||
'service_edit_sms_sender',
|
||||
'service_email_reply_to',
|
||||
'service_letter_contact_details',
|
||||
'service_letter_validation_preview',
|
||||
'service_name_change',
|
||||
'service_name_change_confirm',
|
||||
'service_preview_email_branding',
|
||||
@@ -940,6 +943,7 @@ class OrgNavigation(Navigation):
|
||||
'service_edit_sms_sender',
|
||||
'service_email_reply_to',
|
||||
'service_letter_contact_details',
|
||||
'service_letter_validation_preview',
|
||||
'service_name_change',
|
||||
'service_name_change_confirm',
|
||||
'service_preview_email_branding',
|
||||
|
||||
37
app/templates/views/letter-validation-preview.html
Normal file
37
app/templates/views/letter-validation-preview.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{% extends "withnav_template.html" %}
|
||||
{% from "components/banner.html" import banner %}
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
{% from "components/file-upload.html" import file_upload %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
{% from "components/form.html" import form_wrapper %}
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="grid-row">
|
||||
<div class="column-whole">
|
||||
{% if result %}
|
||||
{{ banner(message, with_tick=True) }}
|
||||
{% elif message %}
|
||||
{{ banner(message, 'dangerous')}}
|
||||
{% endif %}
|
||||
|
||||
<h1 class="heading-large">Letter Validation Preview</h1>
|
||||
<div class="bottom-gutter">
|
||||
{{ file_upload(
|
||||
form.file,
|
||||
action = url_for('main.services_letter_validation_preview', service_id=current_service.id),
|
||||
button_text='Upload a PDF document',
|
||||
)}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column-whole template-container" >
|
||||
|
||||
{% for page in pages %}
|
||||
<div class="letter">
|
||||
<img src="data:image/png;base64,{{ page }}">
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user