# 86 More log details Documents
* adds more log details on adding/removing documents * fixes bug in admin backend where restoring of non-compensation entries led to an error * fixes bug where deleting of revocation without an attached file would lead to an error
This commit is contained in:
@@ -9,6 +9,8 @@ Created on: 15.11.21
|
||||
import shutil
|
||||
|
||||
from django.contrib.gis.db import models
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
from konova.models import BaseResource, AbstractDocument, generate_document_file_upload_path
|
||||
from konova.utils.message_templates import REVOCATION_REMOVED
|
||||
|
||||
@@ -21,10 +23,13 @@ class Revocation(BaseResource):
|
||||
legal = models.ForeignKey("Legal", null=False, blank=False, on_delete=models.CASCADE, help_text="Refers to 'Widerspruch am'", related_name="revocations")
|
||||
comment = models.TextField(null=True, blank=True)
|
||||
|
||||
def delete(self, user = None, *args, **kwargs):
|
||||
def delete(self, user=None, *args, **kwargs):
|
||||
# Make sure related objects are being removed as well
|
||||
if self.document:
|
||||
try:
|
||||
self.document.delete(*args, **kwargs)
|
||||
except ObjectDoesNotExist:
|
||||
# No file to delete
|
||||
pass
|
||||
|
||||
if user is not None:
|
||||
self.legal.intervention.mark_as_edited(user, edit_comment=REVOCATION_REMOVED)
|
||||
|
||||
Reference in New Issue
Block a user