diff --git a/app/__init__.py b/app/__init__.py index acd4f73bc..643a9cd02 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -101,12 +101,14 @@ def create_app(): application.add_template_filter(nl2br) application.add_template_filter(format_datetime) + application.add_template_filter(format_datetime_normal) application.add_template_filter(format_datetime_short) application.add_template_filter(format_time) application.add_template_filter(syntax_highlight_json) application.add_template_filter(valid_phone_number) application.add_template_filter(linkable_name) application.add_template_filter(format_date) + application.add_template_filter(format_date_normal) application.add_template_filter(format_date_short) application.add_template_filter(format_notification_status) @@ -195,6 +197,10 @@ def format_datetime(date): return gmt_timezones(date).strftime('%A %d %B %Y at %H:%M') +def format_datetime_normal(date): + return gmt_timezones(date).strftime('%d %B %Y at %H:%M') + + def format_datetime_short(date): return gmt_timezones(date).strftime('%d %B at %H:%M') @@ -207,6 +213,10 @@ def format_date(date): return gmt_timezones(date).strftime('%A %d %B %Y') +def format_date_normal(date): + return gmt_timezones(date).strftime('%d %B %Y') + + def format_date_short(date): return gmt_timezones(date).strftime('%d %B').lstrip('0') diff --git a/app/assets/stylesheets/components/email-message.scss b/app/assets/stylesheets/components/email-message.scss index a6e27ad5f..338668140 100644 --- a/app/assets/stylesheets/components/email-message.scss +++ b/app/assets/stylesheets/components/email-message.scss @@ -7,7 +7,13 @@ $button-bottom-border-colour: rgba(0, 0, 0, 0.17); &-name { @include bold-24; - margin: 20px 0 10px 0; + margin: 20px 0 5px 0; + } + + &-updated-at { + @include copy-16; + color: $secondary-text-colour; + margin: 0 0 10px 0; } &-meta { diff --git a/app/assets/stylesheets/components/sms-message.scss b/app/assets/stylesheets/components/sms-message.scss index 12d98225c..71778799d 100644 --- a/app/assets/stylesheets/components/sms-message.scss +++ b/app/assets/stylesheets/components/sms-message.scss @@ -36,7 +36,24 @@ .sms-message-name { @include bold-24; - margin: 20px 0 10px 0; + margin: 20px 0 5px 0; +} + +.sms-message-updated-at { + @include copy-16; + color: $secondary-text-colour; + margin: 0 0 10px 0; +} + +.sms-message-use-links-history { + @include copy-16; + color: $secondary-text-colour; + margin: 45px 0 0 0; + + .primary { + color: $text-colour; + + } } .sms-message-picker { @@ -52,7 +69,7 @@ .sms-message-use-links { @include copy-19; - margin-top: -5px; + margin-top: 35px; a { display: block; @@ -73,7 +90,7 @@ .sms-message-use-links-with-title { @extend %sms-message-use-links; - margin-top: 55px; + margin-top: 95px; } .sms-message-from { diff --git a/app/main/views/send.py b/app/main/views/send.py index 8baf787f2..0a95f8854 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -80,7 +80,6 @@ def get_example_csv_rows(template, use_example_as_example=True, submitted_fields def choose_template(service_id, template_type): if template_type not in ['email', 'sms']: abort(404) - return render_template( 'views/templates/choose.html', templates=[ diff --git a/app/templates/components/email-message.html b/app/templates/components/email-message.html index 31e62f05c..46deda0f7 100644 --- a/app/templates/components/email-message.html +++ b/app/templates/components/email-message.html @@ -6,7 +6,13 @@ from_name=None, from_address=None, recipient=None, - show_placeholder_for_recipient=False + id=None, + created_at=None, + updated_at=None, + versions_url=None, + version=1, + show_placeholder_for_recipient=False, + show_id=False ) %} {% if name %}

@@ -15,9 +21,17 @@ {% else %} {{ name }} {% endif %} - {% if created_at %}{{ created_at }}{% endif %}

{% endif %} + {% if version > 1 %} + {% if updated_at %} +

Last updated on {{ updated_at|format_date_normal }} see earlier versions

+ {% endif %} + {% else %} + {% if created_at %} +

Created on {{ created_at|format_date_normal }}

+ {% endif %} + {% endif %}
{% if from_name or subject %} diff --git a/app/templates/components/sms-message.html b/app/templates/components/sms-message.html index 13e8c123a..b3a34fd8f 100644 --- a/app/templates/components/sms-message.html +++ b/app/templates/components/sms-message.html @@ -5,7 +5,12 @@ id=None, edit_link=None, from=None, - show_placeholder_for_recipient=False + version=1, + created_at=None, + updated_at=None, + versions_url=None, + show_placeholder_for_recipient=False, + show_id=False ) %} {% if name %}

@@ -14,9 +19,17 @@ {% else %} {{ name }} {% endif %} - {% if created_at %}{{ created_at }}{% endif %}

{% endif %} + {% if version > 1 %} + {% if updated_at %} +

Last updated on {{ updated_at|format_date_normal }} see earlier versions

+ {% endif %} + {% else %} + {% if created_at %} +

Created on {{ created_at|format_date_normal }}

+ {% endif %} + {% endif %} {% if recipient is not none %}

To: @@ -37,7 +50,7 @@ {% endif %} {{ body|nl2br }} - {% if id %} + {% if show_id %}

Template ID: {{ id }}

diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html index 397459467..0b80e0a02 100644 --- a/app/templates/views/templates/_template.html +++ b/app/templates/views/templates/_template.html @@ -2,16 +2,27 @@ {% from "components/sms-message.html" import sms_message %}
+{{ template.versions }} {% if 'email' == template.template_type %} {{ email_message( template.formatted_subject_as_markup, template.formatted_as_markup, - name=template.name if show_title else None + name=template.name if show_title else None, + id=template.id, + created_at=template.get_raw('created_at', None), + updated_at=template.get_raw('updated_at', None), + version=template.get_raw('version', 1), + versions_url=url_for('.view_template_versions', service_id=current_service.id, template_id=template.id) ) }} {% elif 'sms' == template.template_type %} {{ sms_message( template.formatted_as_markup, - name=template.name if show_title else None + name=template.name if show_title else None, + id=template.id, + created_at=template.get_raw('created_at', None), + updated_at=template.get_raw('updated_at', None), + version=template.get_raw('version', 1), + versions_url=url_for('.view_template_versions', service_id=current_service.id, template_id=template.id) ) }} {% endif %}
@@ -25,7 +36,6 @@ {% if current_user.has_permissions(permissions=['manage_templates'], admin_override=True) %} Edit template {% endif %} - Template versionsAPI info \ No newline at end of file diff --git a/app/templates/views/templates/_template_history.html b/app/templates/views/templates/_template_history.html index d4bb80fa1..a4c990157 100644 --- a/app/templates/views/templates/_template_history.html +++ b/app/templates/views/templates/_template_history.html @@ -29,12 +29,13 @@
-
-

Edited by {{ template.get_raw('created_by').name }}

-

Created on {{ template.get_raw('created_at')|format_datetime }}

-

Edited on - {% if template.get_raw('updated_at') %} - {{ template.get_raw('updated_at')|format_datetime }}

- {% endif %} +
\ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py index bd0265812..cf93f241c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -54,14 +54,14 @@ def template_json(service_id, type_="sms", content="template content", subject=None, - versions='1'): + version=1): template = { 'id': id_, 'name': name, 'template_type': type_, 'content': content, 'service': service_id, - 'version': versions + 'version': version } if subject is not None: template['subject'] = subject