mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Merge pull request #3193 from alphagov/validate-against-empty-messages
Validate CSVs against rows with empty messages
This commit is contained in:
@@ -543,6 +543,7 @@ def _check_messages(service_id, template_id, upload_id, preview_row, letters_as_
|
||||
recipients = RecipientCSV(
|
||||
contents,
|
||||
template_type=template.template_type,
|
||||
template=template,
|
||||
placeholders=template.placeholders,
|
||||
max_initial_rows_shown=50,
|
||||
max_errors_shown=50,
|
||||
|
||||
109
app/templates/govuk_template.html
Normal file
109
app/templates/govuk_template.html
Normal file
@@ -0,0 +1,109 @@
|
||||
{% block top_of_page %}{% endblock %}
|
||||
<!DOCTYPE html>
|
||||
<!--[if lt IE 9]><html class="lte-ie8" lang="{{ html_lang|default('en') }}"><![endif]-->
|
||||
<!--[if gt IE 8]><!--><html lang="{{ html_lang|default('en') }}"><!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>{% block page_title %}GOV.UK - The best place to find government services and information{% endblock %}</title>
|
||||
|
||||
<!--[if gt IE 8]><!--><link rel="stylesheet" media="screen" href="{{ asset_path }}stylesheets/govuk-template.css?0.24.1"/><!--<![endif]-->
|
||||
<!--[if IE 6]><link rel="stylesheet" media="screen" href="{{ asset_path }}stylesheets/govuk-template-ie6.css?0.24.1"/><![endif]-->
|
||||
<!--[if IE 7]><link rel="stylesheet" media="screen" href="{{ asset_path }}stylesheets/govuk-template-ie7.css?0.24.1"/><![endif]-->
|
||||
<!--[if IE 8]><link rel="stylesheet" media="screen" href="{{ asset_path }}stylesheets/govuk-template-ie8.css?0.24.1"/><![endif]-->
|
||||
<link rel="stylesheet" media="print" href="{{ asset_path }}stylesheets/govuk-template-print.css?0.24.1"/>
|
||||
|
||||
<link rel="stylesheet" media="all" href="{{ asset_path }}stylesheets/fonts.css?0.24.1"/>
|
||||
<!--[if lt IE 9]><script src="{{ asset_path }}javascripts/ie.js?0.24.1"></script><![endif]-->
|
||||
|
||||
<link rel="shortcut icon" href="{{ asset_path }}images/favicon.ico?0.24.1" type="image/x-icon" />
|
||||
|
||||
<link rel="mask-icon" href="{{ asset_path }}images/gov.uk_logotype_crown.svg?0.24.1" color="#0b0c0c">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{{ asset_path }}images/apple-touch-icon-180x180.png?0.24.1">
|
||||
<link rel="apple-touch-icon" sizes="167x167" href="{{ asset_path }}images/apple-touch-icon-167x167.png?0.24.1">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="{{ asset_path }}images/apple-touch-icon-152x152.png?0.24.1">
|
||||
<link rel="apple-touch-icon" href="{{ asset_path }}images/apple-touch-icon.png?0.24.1">
|
||||
|
||||
|
||||
<meta name="theme-color" content="#0b0c0c" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
{% block head %}{% endblock %}
|
||||
|
||||
|
||||
<meta property="og:image" content="{{ asset_path }}images/opengraph-image.png?0.24.1">
|
||||
</head>
|
||||
|
||||
<body class="{% block body_classes %}{% endblock %}">
|
||||
<script>document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script>
|
||||
|
||||
{% block body_start %}{% endblock %}
|
||||
|
||||
<div id="skiplink-container">
|
||||
<div>
|
||||
<a href="#content" class="skiplink">{{ skip_link_message|default('Skip to main content') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="global-cookie-message">
|
||||
|
||||
{% block cookie_message %}{% endblock %}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<header role="banner" id="global-header" class="{% block header_class %}{% endblock %}">
|
||||
<div class="header-wrapper">
|
||||
<div class="header-global">
|
||||
<div class="header-logo">
|
||||
<a href="{{ homepage_url|default('https://www.gov.uk') }}" title="{{ logo_link_title|default('Go to the GOV.UK homepage') }}" id="logo" class="content">
|
||||
<img src="{{ asset_path }}images/gov.uk_logotype_crown_invert_trans.png?0.24.1" width="36" height="32" alt=""> {{ global_header_text|default('GOV.UK') }}
|
||||
</a>
|
||||
</div>
|
||||
{% block inside_header %}{% endblock %}
|
||||
</div>
|
||||
{% block proposition_header %}{% endblock %}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
{% block after_header %}{% endblock %}
|
||||
|
||||
<div id="global-header-bar"></div>
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
|
||||
<footer class="group js-footer" id="footer" role="contentinfo">
|
||||
|
||||
<div class="footer-wrapper">
|
||||
{% block footer_top %}{% endblock %}
|
||||
|
||||
<div class="footer-meta">
|
||||
<div class="footer-meta-inner">
|
||||
{% block footer_support_links %}{% endblock %}
|
||||
|
||||
<div class="open-government-licence">
|
||||
<p class="logo"><a href="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" rel="license">Open Government Licence</a></p>
|
||||
|
||||
{% block licence_message %}<p>All content is available under the <a href="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" rel="license">Open Government Licence v3.0</a>, except where otherwise stated</p>{% endblock %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="copyright">
|
||||
<a href="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/">{{ crown_copyright_message|default('© Crown copyright')|safe }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<div id="global-app-error" class="app-error hidden"></div>
|
||||
|
||||
<script src="{{ asset_path }}javascripts/govuk-template.js?0.24.1"></script>
|
||||
|
||||
{% block body_end %}{% endblock %}
|
||||
|
||||
|
||||
<script>if (typeof window.GOVUK === 'undefined') document.body.className = document.body.className.replace('js-enabled', '');</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -25,10 +25,10 @@
|
||||
{% call banner_wrapper(type='dangerous') %}
|
||||
{% if row_errors|length == 1 %}
|
||||
<h1 class='banner-title' data-module="track-error" data-error-type="Bad rows" data-error-label="{{ upload_id }}">
|
||||
There is a problem with {{ original_file_name }}
|
||||
There’s a problem with {{ original_file_name }}
|
||||
</h1>
|
||||
<p>
|
||||
You need to {{ row_errors[0] }}
|
||||
You need to {{ row_errors[0] }}.
|
||||
</p>
|
||||
{% else %}
|
||||
<h1 class='banner-title' data-module="track-error" data-error-type="Bad rows" data-error-label="{{ upload_id }}">
|
||||
|
||||
16
app/utils.py
16
app/utils.py
@@ -131,6 +131,22 @@ def get_errors_for_csv(recipients, template_type):
|
||||
else:
|
||||
errors.append("enter missing data in {} rows".format(number_of_rows_with_missing_data))
|
||||
|
||||
if any(recipients.rows_with_message_too_long):
|
||||
number_of_rows_with_message_too_long = len(list(recipients.rows_with_message_too_long))
|
||||
if 1 == number_of_rows_with_message_too_long:
|
||||
errors.append("shorten the message in 1 row")
|
||||
else:
|
||||
errors.append("shorten the messages in {} rows".format(number_of_rows_with_message_too_long))
|
||||
|
||||
if any(recipients.rows_with_empty_message):
|
||||
number_of_rows_with_empty_message = len(list(recipients.rows_with_empty_message))
|
||||
if 1 == number_of_rows_with_empty_message:
|
||||
errors.append("check you have content for the empty message in 1 row")
|
||||
else:
|
||||
errors.append("check you have content for the empty messages in {} rows".format(
|
||||
number_of_rows_with_empty_message
|
||||
))
|
||||
|
||||
return errors
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user