#31 API POST Compensation

* adds initialize_objects to an abstractmethod of the super class to be implemented in subclasses
* differentiates error messages if intervention does not exist or is just not shared with the user
This commit is contained in:
2022-01-24 14:51:50 +01:00
parent fa01733815
commit 08ab36ffda
2 changed files with 19 additions and 2 deletions

View File

@@ -133,4 +133,19 @@ class AbstractModelAPISerializer:
return self.model.objects.get(
id=id,
users__in=[user]
)
)
@abstractmethod
def initialize_objects(self, json_model, user):
""" Initializes all needed objects from the json_model data
Does not persist data to the DB!
Args:
json_model (dict): The json data
user (User): The API user
Returns:
obj (Intervention)
"""
raise NotImplementedError("Must be implemented in subclasses")