From b450a349a37cadc6f3034df0195e60df8f949592 Mon Sep 17 00:00:00 2001
From: Chris Hill-Scott
Date: Fri, 23 Jun 2017 15:56:25 +0100
Subject: [PATCH] Revert "Merge pull request #1328 from
alphagov/notification-page-reworked"
This reverts commit 17971622488c284925ab57a20eaf00047e47d41c, reversing
changes made to 95b4d9eb318a6bdc375e4e39b2bf5632420dd131.
---
app/assets/stylesheets/main.scss | 1 -
app/assets/stylesheets/views/dashboard.scss | 17 ++--
.../stylesheets/views/notification.scss | 18 -----
app/main/views/jobs.py | 47 +++++------
app/main/views/notifications.py | 77 +++++++++++++------
app/templates/components/table.html | 2 -
app/templates/main_nav.html | 2 +-
.../partials/jobs/notifications.html | 9 +--
app/templates/partials/jobs/status.html | 2 +-
.../partials/notifications/status.html | 13 +---
.../views/activity/notifications.html | 16 +++-
.../dashboard/all-template-statistics.html | 8 +-
app/templates/views/dashboard/inbox.html | 4 +-
.../views/dashboard/template-statistics.html | 8 +-
app/templates/views/jobs/job.html | 9 +++
.../views/notifications/notification.html | 22 ++----
tests/__init__.py | 10 +--
tests/app/main/views/test_activity.py | 12 +--
tests/app/main/views/test_jobs.py | 21 ++---
tests/app/main/views/test_notifications.py | 76 +++++++++++-------
tests/conftest.py | 3 +-
21 files changed, 195 insertions(+), 182 deletions(-)
delete mode 100644 app/assets/stylesheets/views/notification.scss
diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss
index 89b283ddd..29c376245 100644
--- a/app/assets/stylesheets/main.scss
+++ b/app/assets/stylesheets/main.scss
@@ -66,7 +66,6 @@ $path: '/static/images/';
@import 'views/api';
@import 'views/product-page';
@import 'views/template';
-@import 'views/notification';
// TODO: break this up
@import 'app';
diff --git a/app/assets/stylesheets/views/dashboard.scss b/app/assets/stylesheets/views/dashboard.scss
index c3bc7b9b7..a1fed973a 100644
--- a/app/assets/stylesheets/views/dashboard.scss
+++ b/app/assets/stylesheets/views/dashboard.scss
@@ -46,6 +46,17 @@
transition: width 0.6s ease-in-out;
}
+ &-label {
+ @include bold-19;
+ display: block;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ color: $govuk-blue;
+ max-width: 100%;
+ background: $white;
+ }
+
}
.file-list {
@@ -56,17 +67,12 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
- padding-bottom: 30px;
- padding-top: 10px;
- margin-bottom: -30px;
- margin-top: -10px;
}
&-hint {
@include core-16;
display: block;
color: $secondary-text-colour;
- pointer-events: none;
}
}
@@ -90,6 +96,5 @@
}
.align-with-message-body {
- display: block;
margin-top: $gutter * 5 / 6;
}
diff --git a/app/assets/stylesheets/views/notification.scss b/app/assets/stylesheets/views/notification.scss
deleted file mode 100644
index 08def6684..000000000
--- a/app/assets/stylesheets/views/notification.scss
+++ /dev/null
@@ -1,18 +0,0 @@
-.notification-status {
-
- @include core-16;
- color: $secondary-text-colour;
- margin-top: -$gutter-half;
-
- &.error {
-
- color: $error-colour;
- font-weight: bold;
-
- a {
- color: $error-colour;
- }
-
- }
-
-}
diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py
index 17d9996ed..266811651 100644
--- a/app/main/views/jobs.py
+++ b/app/main/views/jobs.py
@@ -14,10 +14,6 @@ from flask import (
stream_with_context
)
from flask_login import login_required
-from notifications_utils.template import (
- Template,
- WithSubjectTemplate,
-)
from werkzeug.datastructures import MultiDict
from app import (
@@ -114,7 +110,21 @@ def view_job(service_id, job_id):
'views/jobs/job.html',
finished=(total_notifications == processed_notifications),
uploaded_file_name=job['original_file_name'],
- template_id=job['template'],
+ template=get_template(
+ service_api_client.get_service_template(
+ service_id=service_id,
+ template_id=job['template'],
+ version=job['template_version']
+ )['data'],
+ current_service,
+ letter_preview_url=url_for(
+ '.view_template_version_preview',
+ service_id=service_id,
+ template_id=job['template'],
+ version=job['template_version'],
+ filetype='png',
+ ),
+ ),
status=request.args.get('status', ''),
updates_url=url_for(
".view_job_updates",
@@ -261,7 +271,7 @@ def get_notifications(service_id, message_type, status_override=None):
),
'notifications': render_template(
'views/activity/notifications.html',
- notifications=add_preview_of_content_to_notifications(notifications['notifications']),
+ notifications=notifications['notifications'],
page=page,
prev_page=prev_page,
next_page=next_page,
@@ -350,11 +360,6 @@ def get_job_partials(job):
notifications = notification_api_client.get_notifications_for_service(
job['service'], job['id'], status=filter_args['status']
)
- template = service_api_client.get_service_template(
- service_id=current_service['id'],
- template_id=job['template'],
- version=job['template_version']
- )['data']
return {
'counts': render_template(
'partials/count.html',
@@ -363,7 +368,7 @@ def get_job_partials(job):
),
'notifications': render_template(
'partials/jobs/notifications.html',
- notifications=add_preview_of_content_to_notifications(notifications['notifications']),
+ notifications=notifications['notifications'],
more_than_one_page=bool(notifications.get('links', {}).get('next')),
percentage_complete=(job['notifications_requested'] / job['notification_count'] * 100),
download_link=url_for(
@@ -374,26 +379,10 @@ def get_job_partials(job):
),
help=get_help_argument(),
time_left=get_time_left(job['created_at']),
- job=job,
- template=template,
- template_version=job['template_version'],
+ job=job
),
'status': render_template(
'partials/jobs/status.html',
job=job
),
}
-
-
-def add_preview_of_content_to_notifications(notifications):
- return (
- dict(
- preview_of_content=(
- str(Template(notification['template'], notification['personalisation']))
- if notification['template']['template_type'] == 'sms' else
- WithSubjectTemplate(notification['template'], notification['personalisation']).subject
- ),
- **notification
- )
- for notification in notifications
- )
diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py
index 20d309a21..ec51789bd 100644
--- a/app/main/views/notifications.py
+++ b/app/main/views/notifications.py
@@ -10,7 +10,6 @@ from flask_login import login_required
from app import (
notification_api_client,
- job_api_client,
current_service
)
from app.main import main
@@ -40,34 +39,27 @@ def get_status_arg(filter_args):
return REQUESTED_STATUSES
-@main.route("/services//notification/")
+@main.route("/services//one-off-notification/")
@login_required
@user_has_permissions('view_activity', admin_override=True)
def view_notification(service_id, notification_id):
notification = notification_api_client.get_notification(service_id, notification_id)
- template = get_template(
- notification['template'],
- current_service,
- letter_preview_url=url_for(
- '.view_template_version_preview',
- service_id=service_id,
- template_id=notification['template']['id'],
- version=notification['template_version'],
- filetype='png',
- ),
- show_recipient=True,
- )
- template.values = notification['personalisation']
- if notification['job']:
- job = job_api_client.get_job(service_id, notification['job']['id'])['data']
- else:
- job = None
return render_template(
'views/notifications/notification.html',
finished=(notification['status'] in (DELIVERED_STATUSES + FAILURE_STATUSES)),
uploaded_file_name='Report',
- template=template,
- job=job,
+ template=get_template(
+ notification['template'],
+ current_service,
+ letter_preview_url=url_for(
+ '.view_template_version_preview',
+ service_id=service_id,
+ template_id=notification['template']['id'],
+ version=notification['template_version'],
+ filetype='png',
+ ),
+ ),
+ status=request.args.get('status'),
updates_url=url_for(
".view_notification_updates",
service_id=service_id,
@@ -76,13 +68,11 @@ def view_notification(service_id, notification_id):
help=get_help_argument()
),
partials=get_single_notification_partials(notification),
- created_by=notification.get('created_by'),
- created_at=notification['created_at'],
help=get_help_argument()
)
-@main.route("/services//notification/.json")
+@main.route("/services//one-off-notification/.json")
@user_has_permissions('view_activity', admin_override=True)
def view_notification_updates(service_id, notification_id):
return jsonify(**get_single_notification_partials(
@@ -90,10 +80,49 @@ def view_notification_updates(service_id, notification_id):
))
+def _get_single_notification_counts(notification, help_argument):
+ return [
+ (
+ label,
+ query_param,
+ url_for(
+ ".view_notification",
+ service_id=notification['service'],
+ notification_id=notification['id'],
+ status=query_param,
+ help=help_argument
+ ),
+ count
+ ) for label, query_param, count in [
+ [
+ 'total', '',
+ 1
+ ],
+ [
+ 'sending', 'sending',
+ int(notification['status'] in SENDING_STATUSES)
+ ],
+ [
+ 'delivered', 'delivered',
+ int(notification['status'] in DELIVERED_STATUSES)
+ ],
+ [
+ 'failed', 'failed',
+ int(notification['status'] in FAILURE_STATUSES)
+ ]
+ ]
+ ]
+
+
def get_single_notification_partials(notification):
status_args = get_status_arg(request.args)
return {
+ 'counts': render_template(
+ 'partials/count.html',
+ counts=_get_single_notification_counts(notification, request.args.get('help', 0)),
+ status=status_args
+ ),
'notifications': render_template(
'partials/notifications/notifications.html',
notification=notification,
diff --git a/app/templates/components/table.html b/app/templates/components/table.html
index 5ad942fe6..8708465b2 100644
--- a/app/templates/components/table.html
+++ b/app/templates/components/table.html
@@ -120,7 +120,6 @@
{% macro notification_status_field(notification) %}
{% call field(status=notification.status|format_notification_status_as_field_status, align='right') %}
- {% if notification.status in ['created', 'sending', 'delivered'] %}{% endif %}
{% if notification.status|format_notification_status_as_url %}
{% endif %}
@@ -136,7 +135,6 @@
(notification.updated_at or notification.created_at)|format_datetime_short
) }}
- {% if notification.status in ['created', 'sending', 'delivered'] %}{% endif %}
{% endcall %}
{% endmacro %}
diff --git a/app/templates/main_nav.html b/app/templates/main_nav.html
index 3c0ca9ef2..2dc588d0e 100644
--- a/app/templates/main_nav.html
+++ b/app/templates/main_nav.html
@@ -32,7 +32,7 @@
Notify delivers the message
{% if help == '3' %}
-
+
Now go to your dashboard
{% endif %}
diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html
index 4bec657b3..8c2964bdd 100644
--- a/app/templates/partials/jobs/notifications.html
+++ b/app/templates/partials/jobs/notifications.html
@@ -5,9 +5,7 @@
{% if job.job_status == 'scheduled' %}
- Sending
- {{ template.name }}
- {{ job.scheduled_for|format_datetime_relative }}
+ Sending will start {{ job.scheduled_for|format_datetime_relative }}