mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-27 02:08:28 -04:00
Refactor template navigation options into model
This has two advantages: - less logic in the view - lets us filer the available navigation by which channels (email, text letter) a service has available
This commit is contained in:
@@ -36,6 +36,12 @@ class Service():
|
||||
'service_callback_api',
|
||||
}
|
||||
|
||||
TEMPLATE_TYPES = (
|
||||
('sms', 'Text message'),
|
||||
('email', 'Email'),
|
||||
('letter', 'Letter'),
|
||||
)
|
||||
|
||||
def __init__(self, _dict):
|
||||
# in the case of a bad request current service may be `None`
|
||||
self._dict = _dict or {}
|
||||
@@ -116,10 +122,17 @@ class Service():
|
||||
@property
|
||||
def available_template_types(self):
|
||||
return [
|
||||
channel for channel in ('email', 'sms', 'letter')
|
||||
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)
|
||||
]
|
||||
|
||||
@property
|
||||
def has_templates(self):
|
||||
return len(self.all_templates) > 0
|
||||
|
||||
Reference in New Issue
Block a user