mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Don’t allow indexing on service model
Making people use a property is a sure way to make sure they’re spelling the name of the property correctly, and allows us to easily swap out properties that call through to the underlying JSON, and properties which are implemented as methods.
This commit is contained in:
@@ -273,6 +273,7 @@ class Service():
|
||||
|
||||
ALLOWED_PROPERTIES = {
|
||||
'active',
|
||||
'contact_link',
|
||||
'dvla_organisation',
|
||||
'email_branding',
|
||||
'email_from',
|
||||
@@ -305,7 +306,9 @@ class Service():
|
||||
raise AttributeError('`{}` is not a service attribute'.format(attr))
|
||||
|
||||
def __getitem__(self, attr):
|
||||
return self.__getattr__(attr)
|
||||
raise NotImplementedError(
|
||||
'Use current_service.{} instead of current_service[\'{}\']'.format(attr, attr)
|
||||
)
|
||||
|
||||
def get(self, attr, default=None):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user