Set accepted files for branding upload

This commit is contained in:
Tom Byers
2020-12-16 11:24:52 +00:00
parent 1096d1f707
commit 51cc2a5296
4 changed files with 6 additions and 2 deletions

View File

@@ -24,7 +24,7 @@
<p class="govuk-body">
Logos should be PNG files, 108px high
</p>
{{ file_upload(form.file, button_text='{} logo'.format('Update' if email_branding else 'Upload')) }}
{{ file_upload(form.file, allowed_file_extensions='.png', button_text='{} logo'.format('Update' if email_branding else 'Upload')) }}
{% call form_wrapper() %}
<div class="form-group">
<div style='margin-top:15px;'>{{form.name}}</div>

View File

@@ -24,7 +24,7 @@
<p class="govuk-body">
Logos should be SVG files, cropped to artwork bounds and with all fonts outlined.
</p>
{{ file_upload(file_upload_form.file, button_text='{} logo'.format('Update' if is_update else 'Upload')) }}
{{ file_upload(file_upload_form.file, allowed_file_extensions='.svg', button_text='{} logo'.format('Update' if is_update else 'Upload')) }}
{% call form_wrapper() %}
<div class="form-group">
{{ letter_branding_details_form.name(param_extensions={

View File

@@ -61,6 +61,7 @@ def test_edit_email_branding_shows_the_correct_branding_info(
assert page.select_one('#logo-img > img')['src'].endswith('/example.png')
assert page.select_one('#name').attrs.get('value') == 'Organisation name'
assert page.select_one('#file').attrs.get('accept') == '.png'
assert page.select_one('#text').attrs.get('value') == 'Organisation text'
assert page.select_one('#colour').attrs.get('value') == '#f00'
@@ -79,6 +80,7 @@ def test_create_email_branding_does_not_show_any_branding_info(
assert page.select_one('#logo-img > img') is None
assert page.select_one('#name').attrs.get('value') is None
assert page.select_one('#file').attrs.get('accept') == '.png'
assert page.select_one('#text').attrs.get('value') is None
assert page.select_one('#colour').attrs.get('value') is None

View File

@@ -62,6 +62,7 @@ def test_update_letter_branding_shows_the_current_letter_brand(
assert page.find('h1').text == 'Update letter branding'
assert page.select_one('#logo-img > img')['src'].endswith('/hm-government.svg')
assert page.select_one('#name').attrs.get('value') == 'HM Government'
assert page.select_one('#file').attrs.get('accept') == '.svg'
def test_update_letter_branding_with_new_valid_file(
@@ -312,6 +313,7 @@ def test_create_letter_branding_does_not_show_branding_info(platform_admin_clien
assert page.select_one('#logo-img > img') is None
assert page.select_one('#name').attrs.get('value') is None
assert page.select_one('#file').attrs.get('accept') == '.svg'
def test_create_letter_branding_when_uploading_valid_file(