#31 API basic implementation Cleanup
* cleans code * reworks many code fragments into smaller methods and split into super class
This commit is contained in:
@@ -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]
|
||||
)
|
||||
Reference in New Issue
Block a user