#31 API DELETE
* adds support for DELETE method for all relevant objects * improves get_obj_from_db functionality * drops custom compensation logic for get_obj_from_db due to improvement of base method
This commit is contained in:
@@ -11,6 +11,8 @@ from abc import abstractmethod
|
||||
from django.contrib.gis import geos
|
||||
from django.contrib.gis.geos import GEOSGeometry
|
||||
|
||||
from konova.utils.message_templates import DATA_UNSHARED
|
||||
|
||||
|
||||
class AbstractModelAPISerializer:
|
||||
model = None
|
||||
@@ -66,7 +68,7 @@ class AbstractModelAPISerializer:
|
||||
# Return all objects
|
||||
del self.lookup["id"]
|
||||
else:
|
||||
# Return certain objects
|
||||
# Return certain object
|
||||
self.lookup["id"] = _id
|
||||
self.lookup["users__in"] = [user]
|
||||
|
||||
@@ -139,10 +141,14 @@ class AbstractModelAPISerializer:
|
||||
Returns:
|
||||
|
||||
"""
|
||||
return self.model.objects.get(
|
||||
obj = self.model.objects.get(
|
||||
id=id,
|
||||
users__in=[user]
|
||||
deleted__isnull=True,
|
||||
)
|
||||
is_shared = obj.is_shared_with(user)
|
||||
if not is_shared:
|
||||
raise PermissionError(DATA_UNSHARED)
|
||||
return obj
|
||||
|
||||
@abstractmethod
|
||||
def initialize_objects(self, json_model, user):
|
||||
|
||||
Reference in New Issue
Block a user