#86 Log detail enhancements

* restructures removing of related data into separate sub-delete forms for easier logic handling
This commit is contained in:
2022-02-08 13:16:20 +01:00
parent 13fd3e1fcb
commit 6cdf355063
21 changed files with 206 additions and 75 deletions

View File

@@ -11,7 +11,7 @@ from django.contrib.auth.decorators import login_required
from django.http import HttpRequest
from django.shortcuts import get_object_or_404
from compensation.forms.modalForms import NewPaymentForm
from compensation.forms.modalForms import NewPaymentForm, PaymentRemoveModalForm
from compensation.models import Payment
from intervention.models import Intervention
from konova.decorators import default_group_required
@@ -21,39 +21,41 @@ from konova.utils.message_templates import PAYMENT_ADDED, PAYMENT_REMOVED
@login_required
@default_group_required
def new_payment_view(request: HttpRequest, intervention_id: str):
def new_payment_view(request: HttpRequest, id: str):
""" Renders a modal view for adding new payments
Args:
request (HttpRequest): The incoming request
intervention_id (str): The intervention's id for which a new payment shall be added
id (str): The intervention's id for which a new payment shall be added
Returns:
"""
intervention = get_object_or_404(Intervention, id=intervention_id)
intervention = get_object_or_404(Intervention, id=id)
form = NewPaymentForm(request.POST or None, instance=intervention, request=request)
return form.process_request(
request,
msg_success=PAYMENT_ADDED,
redirect_url=reverse("intervention:detail", args=(intervention_id,)) + "#related_data"
redirect_url=reverse("intervention:detail", args=(id,)) + "#related_data"
)
@login_required
@default_group_required
def payment_remove_view(request: HttpRequest, id: str):
def payment_remove_view(request: HttpRequest, id: str, payment_id: str):
""" Renders a modal view for removing payments
Args:
request (HttpRequest): The incoming request
id (str): The payment's id
id (str): The intervention's id
payment_id (str): The payment's id
Returns:
"""
payment = get_object_or_404(Payment, id=id)
form = RemoveModalForm(request.POST or None, instance=payment, request=request)
intervention = get_object_or_404(Intervention, id=id)
payment = get_object_or_404(Payment, id=payment_id)
form = PaymentRemoveModalForm(request.POST or None, instance=intervention, payment=payment, request=request)
return form.process_request(
request=request,
msg_success=PAYMENT_REMOVED,