mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-27 09:29:22 -04:00
Move labels of template types out of model
The model shouldn’t have to care about how things are labelled in the UI, it should only care about the data.
This commit is contained in:
@@ -151,10 +151,19 @@ def template_operation(operation_name, form):
|
||||
return True
|
||||
|
||||
|
||||
def get_template_nav_label(value):
|
||||
return {
|
||||
'all': 'All',
|
||||
'sms': 'Text message',
|
||||
'email': 'Email',
|
||||
'letter': 'Letter',
|
||||
}[value]
|
||||
|
||||
|
||||
def get_template_nav_items(template_folder_id):
|
||||
return [
|
||||
(
|
||||
label,
|
||||
get_template_nav_label(key),
|
||||
key,
|
||||
url_for(
|
||||
'.choose_template', service_id=current_service.id,
|
||||
@@ -162,7 +171,7 @@ def get_template_nav_items(template_folder_id):
|
||||
),
|
||||
''
|
||||
)
|
||||
for label, key in [('All', 'all')] + current_service.available_template_types_as_tuples
|
||||
for key in ['all'] + current_service.available_template_types
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ class Service():
|
||||
}
|
||||
|
||||
TEMPLATE_TYPES = (
|
||||
('sms', 'Text message'),
|
||||
('email', 'Email'),
|
||||
('letter', 'Letter'),
|
||||
'sms',
|
||||
'email',
|
||||
'letter',
|
||||
)
|
||||
|
||||
def __init__(self, _dict):
|
||||
@@ -121,17 +121,7 @@ class Service():
|
||||
|
||||
@property
|
||||
def available_template_types(self):
|
||||
return [
|
||||
channel for channel, _ in self.TEMPLATE_TYPES
|
||||
if self.has_permission(channel)
|
||||
]
|
||||
|
||||
@property
|
||||
def available_template_types_as_tuples(self):
|
||||
return [
|
||||
(label, value) for value, label in self.TEMPLATE_TYPES
|
||||
if self.has_permission(value)
|
||||
]
|
||||
return list(filter(self.has_permission, self.TEMPLATE_TYPES))
|
||||
|
||||
@property
|
||||
def has_templates(self):
|
||||
|
||||
Reference in New Issue
Block a user