mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 13:39:41 -04:00
Put template content or subject in tables
In tables where we show rows and rows of information we used to give some meta information about the notification, or at least as much as we could give in the very limited space available. This information is now on the notifications page, so the information we show in these tables should just be whatever helps users identify the right message. I reckon that this is: - the content of the message for text messages - the subject for emails and letters This also makes these pages consistent with: - the inbound SMS page - the way the people’s inboxes work for their text messsages/Whatsapps/emails For consistency’s sake this makes the job page work the same way. It may be slightly less useful here because on the job page every message is sent from the same template, so will have broadly the same content.
This commit is contained in:
@@ -14,6 +14,10 @@ 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 (
|
||||
@@ -271,7 +275,7 @@ def get_notifications(service_id, message_type, status_override=None):
|
||||
),
|
||||
'notifications': render_template(
|
||||
'views/activity/notifications.html',
|
||||
notifications=notifications['notifications'],
|
||||
notifications=add_preview_of_content_to_notifications(notifications['notifications']),
|
||||
page=page,
|
||||
prev_page=prev_page,
|
||||
next_page=next_page,
|
||||
@@ -368,7 +372,7 @@ def get_job_partials(job):
|
||||
),
|
||||
'notifications': render_template(
|
||||
'partials/jobs/notifications.html',
|
||||
notifications=notifications['notifications'],
|
||||
notifications=add_preview_of_content_to_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(
|
||||
@@ -386,3 +390,17 @@ def get_job_partials(job):
|
||||
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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user