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:
Chris Hill-Scott
2018-11-12 09:16:14 +00:00
parent c18a38d4f1
commit 40f676d3ad
2 changed files with 15 additions and 16 deletions

View File

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