give test letter api notifications a different filename

so they can be distinguished on the frontend.

Also, some related cleanup:

* don't show test api letters on the frontpage
* make sure the subject is returned from the API for letters
* make sure the letter's address is returned for letters
This commit is contained in:
Leo Hemsted
2017-08-01 18:23:29 +01:00
parent 075d2a3346
commit 13917c9c57
6 changed files with 45 additions and 8 deletions

View File

@@ -891,7 +891,7 @@ class Notification(db.Model):
@property
def subject(self):
from app.utils import get_template_instance
if self.notification_type == EMAIL_TYPE:
if self.notification_type != SMS_TYPE:
template_object = get_template_instance(self.template.__dict__, self.personalisation)
return template_object.subject
@@ -971,10 +971,24 @@ class Notification(db.Model):
"created_at": self.created_at.strftime(DATETIME_FORMAT),
"sent_at": self.sent_at.strftime(DATETIME_FORMAT) if self.sent_at else None,
"completed_at": self.completed_at(),
"scheduled_for": convert_bst_to_utc(self.scheduled_notification.scheduled_for
).strftime(DATETIME_FORMAT) if self.scheduled_notification else None
"scheduled_for": (
convert_bst_to_utc(
self.scheduled_notification.scheduled_for
).strftime(DATETIME_FORMAT)
if self.scheduled_notification
else None
)
}
if self.notification_type == LETTER_TYPE:
serialized['line_1'] = self.personalisation['address_line_1']
serialized['line_2'] = self.personalisation.get('address_line_2')
serialized['line_3'] = self.personalisation.get('address_line_3')
serialized['line_4'] = self.personalisation.get('address_line_4')
serialized['line_5'] = self.personalisation.get('address_line_5')
serialized['line_6'] = self.personalisation.get('address_line_6')
serialized['postcode'] = self.personalisation['postcode']
return serialized