Raise exception when overriding a custom property

If a subclass of `JSONModel` defines a property then we shouldn’t try
to override it with the value from the underlying dictionary.

Rather than silently fail we should raise an exception because it will
help keep our list of `ALLOWED_PROPERTIES` nice and tidy.
This commit is contained in:
Chris Hill-Scott
2020-10-28 10:03:02 +00:00
parent 89c63e3243
commit 38e9e84f77
3 changed files with 7 additions and 5 deletions

View File

@@ -13,7 +13,7 @@ class JSONModel(SerialisedModel):
# in the case of a bad request _dict may be `None`
self._dict = _dict or {}
for property in self.ALLOWED_PROPERTIES:
if property in self._dict and not hasattr(self, property):
if property in self._dict:
setattr(self, property, self._dict[property])
def __bool__(self):

View File

@@ -28,7 +28,6 @@ class Job(JSONModel):
'template_version',
'original_file_name',
'created_at',
'processing_started',
'notification_count',
'created_by',
'template_type',