mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
Update message for last used template on delete:
* API now returns an empty response if a template was last used more than seven * days ago * Handle the empty response appropriately
This commit is contained in:
@@ -428,12 +428,13 @@ def delete_service_template(service_id, template_id):
|
||||
last_used_notification = template_statistics_client.get_template_statistics_for_template(
|
||||
service_id, template['id']
|
||||
)
|
||||
message = 'It was last used {} ago.'.format(
|
||||
get_human_readable_delta(
|
||||
message = 'It was last used {} ago'.format(
|
||||
'more than seven days' if not last_used_notification else get_human_readable_delta(
|
||||
parse(last_used_notification['created_at']).replace(tzinfo=None),
|
||||
datetime.utcnow()
|
||||
)
|
||||
)
|
||||
|
||||
except HTTPError as e:
|
||||
if e.status_code == 404:
|
||||
message = None
|
||||
|
||||
Reference in New Issue
Block a user