#31 API basic implementation Cleanup

* cleans code
* reworks many code fragments into smaller methods and split into super class
This commit is contained in:
2022-01-24 13:12:29 +01:00
parent b1a42b126e
commit 5ad1b35dc0
2 changed files with 50 additions and 1 deletions

View File

@@ -117,4 +117,21 @@ class AbstractModelAPISerializer:
if isinstance(geojson, dict):
geojson = json.dumps(geojson)
geometry = geos.fromstr(geojson)
return geometry
return geometry
def get_obj_from_db(self, id, user):
""" Returns the object from database
Fails if id not found or user does not have shared access
Args:
id (str): The object's id
user (User): The API user
Returns:
"""
return self.model.objects.get(
id=id,
users__in=[user]
)