Updated copy on the page.

Added unit tests.
Added error when file is too big.
This commit is contained in:
Rebecca Law
2019-03-20 11:31:29 +00:00
parent 8fd5fa90ff
commit 42e63667f7
4 changed files with 61 additions and 3 deletions

View File

@@ -280,6 +280,14 @@ def letter_validation_preview(from_platform_admin):
), 400
try:
if len(pdf_file.read()) > (2 * 1024 * 1024):
return render_template(
view_location,
form=form,
message="File must be less than 2MB",
pages=pages, result=result
), 400
pdf_file.seek(0)
response = validate_letter(pdf_file)
response.raise_for_status()
if response.status_code == 200:

View File

@@ -5,6 +5,11 @@
{% from "components/page-footer.html" import page_footer %}
{% from "components/form.html" import form_wrapper %}
{% block service_page_title %}
Letter validation preview
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row">
@@ -15,14 +20,29 @@
{{ banner(message, 'dangerous')}}
{% endif %}
<h1 class="heading-large">Letter Validation Preview</h1>
<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',
action = url_for('main.service_letter_validation_preview', service_id=current_service.id),
button_text='Choose a file',
)}}
</div>
{%if not pages %}
<div>
<h1 class="heading-medium">Check your file meets the letter specification </h1>
<p>Your file must be:
<li>a PDF</li>
<li>no more than 10 pages long</li>
<li>less than 2 MB</li>
</p>
<p>The content of your letter mut appear inside the printable area.</p>
<p>
<a href="https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.3.pdf">
Download the letter specification</a> for more information.
</p>
</div>
{% endif%}
</div>
<div class="column-whole template-container" >