mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-04 05:30:53 -04:00
Group 'completed' notification statuses
Some notification statuses assume that a notification has been updated (ie, it cannot have been created in that state). This caused a bug in our sample notification fixture when trying to create a notificaiton in a 'complete' status. This commit groups the completed statuses in a list, the way other statuses have been grouped together so that they're more portable. Also fixed the sample_notification fixture.
This commit is contained in:
@@ -466,6 +466,14 @@ NOTIFICATION_TECHNICAL_FAILURE = 'technical-failure'
|
||||
NOTIFICATION_TEMPORARY_FAILURE = 'temporary-failure'
|
||||
NOTIFICATION_PERMANENT_FAILURE = 'permanent-failure'
|
||||
|
||||
NOTIFICATION_STATUS_TYPES_COMPLETED = [
|
||||
NOTIFICATION_DELIVERED,
|
||||
NOTIFICATION_FAILED,
|
||||
NOTIFICATION_TECHNICAL_FAILURE,
|
||||
NOTIFICATION_TEMPORARY_FAILURE,
|
||||
NOTIFICATION_PERMANENT_FAILURE,
|
||||
]
|
||||
|
||||
NOTIFICATION_STATUS_TYPES_BILLABLE = [
|
||||
NOTIFICATION_SENDING,
|
||||
NOTIFICATION_DELIVERED,
|
||||
@@ -545,13 +553,7 @@ class Notification(db.Model):
|
||||
self._personalisation = encryption.encrypt(personalisation)
|
||||
|
||||
def completed_at(self):
|
||||
if self.status in [
|
||||
NOTIFICATION_DELIVERED,
|
||||
NOTIFICATION_FAILED,
|
||||
NOTIFICATION_TECHNICAL_FAILURE,
|
||||
NOTIFICATION_TEMPORARY_FAILURE,
|
||||
NOTIFICATION_PERMANENT_FAILURE,
|
||||
]:
|
||||
if self.status in NOTIFICATION_STATUS_TYPES_COMPLETED:
|
||||
return self.updated_at.strftime(DATETIME_FORMAT)
|
||||
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user