#86 Userlogs Revocation

* reworks user logs for adding/removing revocations with more detail on log history
* enhances css to display neat shadow on select2-results
This commit is contained in:
mpeltriaux 2022-02-03 12:10:23 +01:00
parent 05b2f1b2cc
commit 0e48ae6e4a
5 changed files with 21 additions and 6 deletions

View File

@ -7,7 +7,7 @@ Created on: 27.09.21
""" """
from dal import autocomplete from dal import autocomplete
from konova.utils.message_templates import DEDUCTION_ADDED from konova.utils.message_templates import DEDUCTION_ADDED, REVOCATION_ADDED
from user.models import User, UserActionLogEntry from user.models import User, UserActionLogEntry
from django.db import transaction from django.db import transaction
from django import forms from django import forms
@ -168,7 +168,7 @@ class NewRevocationModalForm(BaseModalForm):
def save(self): def save(self):
revocation = self.instance.add_revocation(self) revocation = self.instance.add_revocation(self)
self.instance.mark_as_edited(self.user, self.request) self.instance.mark_as_edited(self.user, self.request, edit_comment=REVOCATION_ADDED)
return revocation return revocation

View File

@ -10,6 +10,7 @@ import shutil
from django.contrib.gis.db import models from django.contrib.gis.db import models
from konova.models import BaseResource, AbstractDocument, generate_document_file_upload_path from konova.models import BaseResource, AbstractDocument, generate_document_file_upload_path
from konova.utils.message_templates import REVOCATION_REMOVED
class Revocation(BaseResource): class Revocation(BaseResource):
@ -20,10 +21,14 @@ class Revocation(BaseResource):
legal = models.ForeignKey("Legal", null=False, blank=False, on_delete=models.CASCADE, help_text="Refers to 'Widerspruch am'", related_name="revocations") 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) comment = models.TextField(null=True, blank=True)
def delete(self, *args, **kwargs): def delete(self, user = None, *args, **kwargs):
# Make sure related objects are being removed as well # Make sure related objects are being removed as well
if self.document: if self.document:
self.document.delete(*args, **kwargs) self.document.delete(*args, **kwargs)
if user is not None:
self.legal.intervention.mark_as_edited(user, edit_comment=REVOCATION_REMOVED)
super().delete() super().delete()
@property @property

View File

@ -16,7 +16,7 @@ from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
from konova.utils.documents import remove_document, get_document from konova.utils.documents import remove_document, get_document
from konova.utils.generators import generate_qr_code from konova.utils.generators import generate_qr_code
from konova.utils.message_templates import INTERVENTION_INVALID, FORM_INVALID, IDENTIFIER_REPLACED, \ from konova.utils.message_templates import INTERVENTION_INVALID, FORM_INVALID, IDENTIFIER_REPLACED, \
CHECKED_RECORDED_RESET, DEDUCTION_REMOVED, DEDUCTION_ADDED CHECKED_RECORDED_RESET, DEDUCTION_REMOVED, DEDUCTION_ADDED, REVOCATION_ADDED, REVOCATION_REMOVED
from konova.utils.user_checks import in_group from konova.utils.user_checks import in_group
@ -354,7 +354,7 @@ def remove_revocation_view(request: HttpRequest, id: str):
form = RemoveModalForm(request.POST or None, instance=obj, request=request) form = RemoveModalForm(request.POST or None, instance=obj, request=request)
return form.process_request( return form.process_request(
request, request,
_("Revocation removed"), REVOCATION_REMOVED,
redirect_url=reverse("intervention:detail", args=(obj.intervention.id,)) + "#related_data" redirect_url=reverse("intervention:detail", args=(obj.intervention.id,)) + "#related_data"
) )
@ -459,7 +459,7 @@ def new_revocation_view(request: HttpRequest, id: str):
form = NewRevocationModalForm(request.POST or None, request.FILES or None, instance=intervention, request=request) form = NewRevocationModalForm(request.POST or None, request.FILES or None, instance=intervention, request=request)
return form.process_request( return form.process_request(
request, request,
msg_success=_("Revocation added"), msg_success=REVOCATION_ADDED,
redirect_url=reverse("intervention:detail", args=(id,)) + "#related_data" redirect_url=reverse("intervention:detail", args=(id,)) + "#related_data"
) )

View File

@ -226,6 +226,12 @@ No other approach worked to get the autocomplete fields to full width of parent
.select2{ .select2{
width: 100% !important; width: 100% !important;
} }
/*
Similar to bootstraps 'shadow-lg'
*/
.select2-results{
box-shadow: 0 1rem 3rem rgba(0,0,0,.2) !important;
}
.select2-results__option--highlighted{ .select2-results__option--highlighted{
background-color: var(--rlp-red) !important; background-color: var(--rlp-red) !important;
} }

View File

@ -29,6 +29,10 @@ DEDUCTION_REMOVED = _("Deduction removed")
PAYMENT_ADDED = _("Payment added") PAYMENT_ADDED = _("Payment added")
PAYMENT_REMOVED = _("Payment removed") PAYMENT_REMOVED = _("Payment removed")
# REVOCATIONS
REVOCATION_ADDED = _("Revocation added")
REVOCATION_REMOVED = _("Revocation removed")
# Edited # Edited
EDITED_GENERAL_DATA = _("Edited general data") EDITED_GENERAL_DATA = _("Edited general data")
ADDED_COMPENSATION_STATE = _("Added compensation state") ADDED_COMPENSATION_STATE = _("Added compensation state")