#31 API POST/PUT Intervention

* splits code in smaller, reusable methods
* adds put method to view
* adds update_model_from_json() method
This commit is contained in:
2022-01-24 13:04:39 +01:00
parent 854e358b73
commit b1a42b126e
3 changed files with 108 additions and 36 deletions

View File

@@ -78,6 +78,20 @@ class AbstractModelAPISerializer:
serialized_data = self.model_to_geo_json(entry)
return serialized_data
@abstractmethod
def update_model_from_json(self, id, json_model, user):
""" Updates an instance from given json data
Args:
id (str): The instance's to be updated
json_model (dict): JSON data
user (User): The performing user
Returns:
"""
raise NotImplementedError("Must be implemented in subclasses")
@abstractmethod
def create_model_from_json(self, json_model, user):
""" Creates a new instance from given json data