mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 18:22:37 -04:00
Refactor to not need custom constructor
All the constructor of the service model is doing is setting a default value of a property, this is more idiomatically expressed with a custom property, and means we can get rid of the custom constructor entirely.
This commit is contained in:
@@ -39,7 +39,6 @@ class Service(JSONModel):
|
|||||||
'letter_contact_block',
|
'letter_contact_block',
|
||||||
'message_limit',
|
'message_limit',
|
||||||
'name',
|
'name',
|
||||||
'permissions',
|
|
||||||
'prefix_sms',
|
'prefix_sms',
|
||||||
'research_mode',
|
'research_mode',
|
||||||
'service_callback_api',
|
'service_callback_api',
|
||||||
@@ -68,16 +67,14 @@ class Service(JSONModel):
|
|||||||
'upload_letters',
|
'upload_letters',
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, _dict):
|
|
||||||
|
|
||||||
super().__init__(_dict)
|
|
||||||
if 'permissions' not in self._dict:
|
|
||||||
self.permissions = {'email', 'sms', 'letter'}
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_id(cls, service_id):
|
def from_id(cls, service_id):
|
||||||
return cls(service_api_client.get_service(service_id)['data'])
|
return cls(service_api_client.get_service(service_id)['data'])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def permissions(self):
|
||||||
|
return self._dict.get('permissions', self.TEMPLATE_TYPES)
|
||||||
|
|
||||||
def update(self, **kwargs):
|
def update(self, **kwargs):
|
||||||
return service_api_client.update_service(self.id, **kwargs)
|
return service_api_client.update_service(self.id, **kwargs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user