#31 API basic implementation Cleanup

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

No files matched your search

+18 -1
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]
)