# 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:
@@ -26,7 +26,7 @@ from konova.models import generate_document_file_upload_path, AbstractDocument,
|
||||
ShareableObjectMixin, \
|
||||
RecordableObjectMixin, CheckableObjectMixin, GeoReferencedMixin
|
||||
from konova.settings import LANIS_LINK_TEMPLATE, LANIS_ZOOM_LUT, DEFAULT_SRID_RLP
|
||||
from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION, DEDUCTION_ADDED
|
||||
from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION, DEDUCTION_ADDED, DOCUMENT_REMOVED_TEMPLATE
|
||||
from user.models import UserActionLogEntry
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ class InterventionDocument(AbstractDocument):
|
||||
max_length=1000,
|
||||
)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
def delete(self, user=None, *args, **kwargs):
|
||||
"""
|
||||
Custom delete functionality for InterventionDocuments.
|
||||
Removes the folder from the file system if there are no further documents for this entry.
|
||||
@@ -324,6 +324,9 @@ class InterventionDocument(AbstractDocument):
|
||||
folder_path = self.file.path.split("/")[:-1]
|
||||
folder_path = "/".join(folder_path)
|
||||
|
||||
if user:
|
||||
self.instance.mark_as_edited(user, edit_comment=DOCUMENT_REMOVED_TEMPLATE.format(self.title))
|
||||
|
||||
# Remove the file itself
|
||||
super().delete(*args, **kwargs)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -17,7 +17,7 @@ from konova.utils.documents import remove_document, get_document
|
||||
from konova.utils.generators import generate_qr_code
|
||||
from konova.utils.message_templates import INTERVENTION_INVALID, FORM_INVALID, IDENTIFIER_REPLACED, \
|
||||
CHECKED_RECORDED_RESET, DEDUCTION_REMOVED, DEDUCTION_ADDED, REVOCATION_ADDED, REVOCATION_REMOVED, \
|
||||
COMPENSATION_REMOVED_TEMPLATE
|
||||
COMPENSATION_REMOVED_TEMPLATE, DOCUMENT_ADDED
|
||||
from konova.utils.user_checks import in_group
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ def new_document_view(request: HttpRequest, id: str):
|
||||
form = NewInterventionDocumentForm(request.POST or None, request.FILES or None, instance=intervention, request=request)
|
||||
return form.process_request(
|
||||
request,
|
||||
msg_success=_("Document added"),
|
||||
msg_success=DOCUMENT_ADDED,
|
||||
redirect_url=reverse("intervention:detail", args=(id,)) + "#related_data"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user