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:
Imdad Ahad
2017-07-26 12:04:07 +01:00
parent 21c8b6a8bf
commit 5a81064f07
3 changed files with 36 additions and 4 deletions

View File

@@ -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