mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Return hidden field as part of json for notification by id
- required by Admin app so that it can distinguish between created and precompiled letters
This commit is contained in:
@@ -454,7 +454,7 @@ class NotificationWithTemplateSchema(BaseSchema):
|
||||
|
||||
template = fields.Nested(
|
||||
TemplateSchema,
|
||||
only=['id', 'version', 'name', 'template_type', 'content', 'subject', 'redact_personalisation'],
|
||||
only=['id', 'version', 'name', 'template_type', 'content', 'subject', 'redact_personalisation', 'hidden'],
|
||||
dump_only=True
|
||||
)
|
||||
job = fields.Nested(JobSchema, only=["id", "original_file_name"], dump_only=True)
|
||||
|
||||
@@ -125,13 +125,13 @@ def create_service_with_defined_sms_sender(
|
||||
|
||||
|
||||
def create_template(
|
||||
service,
|
||||
template_type=SMS_TYPE,
|
||||
template_name=None,
|
||||
subject='Template subject',
|
||||
content='Dear Sir/Madam, Hello. Yours Truly, The Government.',
|
||||
reply_to=None,
|
||||
hidden=False
|
||||
service,
|
||||
template_type=SMS_TYPE,
|
||||
template_name=None,
|
||||
subject='Template subject',
|
||||
content='Dear Sir/Madam, Hello. Yours Truly, The Government.',
|
||||
reply_to=None,
|
||||
hidden=False
|
||||
):
|
||||
data = {
|
||||
'name': template_name or '{} Template Name'.format(template_type),
|
||||
|
||||
@@ -2139,6 +2139,17 @@ def test_get_notification_for_service_includes_template_redacted(admin_request,
|
||||
assert resp['template']['redact_personalisation'] is False
|
||||
|
||||
|
||||
def test_get_notification_for_service_includes_template_hidden(admin_request, sample_notification):
|
||||
resp = admin_request.get(
|
||||
'service.get_notification_for_service',
|
||||
service_id=sample_notification.service_id,
|
||||
notification_id=sample_notification.id
|
||||
)
|
||||
|
||||
assert resp['id'] == str(sample_notification.id)
|
||||
assert resp['template']['hidden'] is False
|
||||
|
||||
|
||||
def test_get_all_notifications_for_service_includes_template_redacted(admin_request, sample_service):
|
||||
normal_template = create_template(sample_service)
|
||||
|
||||
@@ -2162,6 +2173,33 @@ def test_get_all_notifications_for_service_includes_template_redacted(admin_requ
|
||||
assert resp['notifications'][1]['template']['redact_personalisation'] is True
|
||||
|
||||
|
||||
def test_get_all_notifications_for_service_includes_template_hidden(admin_request, sample_service):
|
||||
letter_template = create_template(sample_service, template_type=LETTER_TYPE)
|
||||
precompiled_template = create_template(
|
||||
sample_service,
|
||||
template_type=LETTER_TYPE,
|
||||
template_name='Pre-compiled PDF',
|
||||
subject='Pre-compiled PDF',
|
||||
hidden=True
|
||||
)
|
||||
|
||||
with freeze_time('2000-01-01'):
|
||||
letter_noti = create_notification(letter_template)
|
||||
with freeze_time('2000-01-02'):
|
||||
precompiled_noti = create_notification(precompiled_template)
|
||||
|
||||
resp = admin_request.get(
|
||||
'service.get_all_notifications_for_service',
|
||||
service_id=sample_service.id
|
||||
)
|
||||
|
||||
assert resp['notifications'][0]['id'] == str(precompiled_noti.id)
|
||||
assert resp['notifications'][0]['template']['hidden'] is True
|
||||
|
||||
assert resp['notifications'][1]['id'] == str(letter_noti.id)
|
||||
assert resp['notifications'][1]['template']['hidden'] is False
|
||||
|
||||
|
||||
def test_search_for_notification_by_to_field_returns_personlisation(
|
||||
client,
|
||||
notify_db,
|
||||
|
||||
Reference in New Issue
Block a user