@ -17,6 +17,7 @@ from codelist.settings import CODELIST_COMPENSATION_ACTION_ID, CODELIST_BIOTOPES
from compensation . models import CompensationAction , UnitChoices , CompensationState
from intervention . models import Responsibility , Legal
from konova . models import Deadline , DeadlineType
from konova . utils . message_templates import DATA_UNSHARED
class AbstractModelAPISerializerV1 ( AbstractModelAPISerializer ) :
@ -101,6 +102,27 @@ class AbstractModelAPISerializerV1(AbstractModelAPISerializer):
modified_on = modified_on . timestamp if modified_on is not None else None
return modified_on
def delete_entry ( self , id , user ) :
""" Marks an entry as deleted
Args :
id ( str ) : The entry ' s id
user ( User ) : The API user
Returns :
"""
entry = self . get_obj_from_db ( id , user )
is_shared = entry . is_shared_with ( user )
if not is_shared :
raise PermissionError ( DATA_UNSHARED )
# Do not send mails if entry is deleting using API. THere could be hundreds of deletion resulting in hundreds of
# mails at once.
entry . mark_as_deleted ( user , send_mail = False )
entry . refresh_from_db ( )
success = entry . deleted is not None
return success
class DeductableAPISerializerV1Mixin :
class Meta :