mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Preview content as hint for broadcast templates
Broadcast services only have broadcast templates. But we show the template type under the name of the template. This is redundant. It would be better to preview the content of the template instead. This then makes the templates page consistent with the dashboard. Depends on: - [ ] https://github.com/alphagov/notifications-api/pull/2996
This commit is contained in:
@@ -409,7 +409,7 @@ def valid_phone_number(phone_number):
|
||||
def format_notification_type(notification_type):
|
||||
return {
|
||||
'email': 'Email',
|
||||
'sms': 'SMS',
|
||||
'sms': 'Text message',
|
||||
'letter': 'Letter'
|
||||
}[notification_type]
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from app import format_notification_type
|
||||
|
||||
|
||||
class TemplateList():
|
||||
|
||||
def __init__(
|
||||
@@ -128,12 +131,17 @@ class TemplateListTemplate(TemplateListItem):
|
||||
):
|
||||
super().__init__(template, ancestors)
|
||||
self.service_id = service_id
|
||||
self.hint = {
|
||||
'email': 'Email template',
|
||||
'sms': 'Text message template',
|
||||
'letter': 'Letter template',
|
||||
'broadcast': 'Broadcast template',
|
||||
}.get(template['template_type'])
|
||||
self.template_type = template['template_type']
|
||||
self.content = template.get('content')
|
||||
|
||||
@property
|
||||
def hint(self):
|
||||
if self.template_type == 'broadcast':
|
||||
max_length_in_chars = 40
|
||||
if len(self.content) > (max_length_in_chars + 2):
|
||||
return self.content[:max_length_in_chars].strip() + '…'
|
||||
return self.content
|
||||
return format_notification_type(self.template_type) + ' template'
|
||||
|
||||
|
||||
class TemplateListFolder(TemplateListItem):
|
||||
|
||||
Reference in New Issue
Block a user