Refactors triggering checked/recorded
* refactors BaseForm request/user initialization * introduces mark_as_edited() method for compensation models
This commit is contained in:
parent
bd36ab5b6f
commit
6cb1a31aff
@ -18,6 +18,7 @@ from compensation.models import Compensation, EcoAccount
|
|||||||
from intervention.inputs import GenerateInput
|
from intervention.inputs import GenerateInput
|
||||||
from intervention.models import Intervention, Responsibility, Legal
|
from intervention.models import Intervention, Responsibility, Legal
|
||||||
from konova.forms import BaseForm, SimpleGeomForm
|
from konova.forms import BaseForm, SimpleGeomForm
|
||||||
|
from konova.utils.message_templates import EDITED_GENERAL_DATA
|
||||||
from user.models import UserActionLogEntry
|
from user.models import UserActionLogEntry
|
||||||
|
|
||||||
|
|
||||||
@ -285,7 +286,7 @@ class EditCompensationForm(NewCompensationForm):
|
|||||||
|
|
||||||
self.instance.log.add(action)
|
self.instance.log.add(action)
|
||||||
|
|
||||||
intervention.mark_as_edited(user)
|
intervention.mark_as_edited(user, self.request, EDITED_GENERAL_DATA)
|
||||||
return self.instance
|
return self.instance
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@ from compensation.models import CompensationDocument, EcoAccountDocument
|
|||||||
from konova.contexts import BaseContext
|
from konova.contexts import BaseContext
|
||||||
from konova.forms import BaseModalForm, NewDocumentForm
|
from konova.forms import BaseModalForm, NewDocumentForm
|
||||||
from konova.models import DeadlineType
|
from konova.models import DeadlineType
|
||||||
from konova.utils.message_templates import FORM_INVALID
|
from konova.utils.message_templates import FORM_INVALID, ADDED_COMPENSATION_STATE, ADDED_DEADLINE, \
|
||||||
|
ADDED_COMPENSATION_ACTION
|
||||||
|
|
||||||
|
|
||||||
class NewPaymentForm(BaseModalForm):
|
class NewPaymentForm(BaseModalForm):
|
||||||
@ -98,6 +99,7 @@ class NewPaymentForm(BaseModalForm):
|
|||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
pay = self.instance.add_payment(self)
|
pay = self.instance.add_payment(self)
|
||||||
|
self.instance.mark_as_edited(self.user, self.request)
|
||||||
return pay
|
return pay
|
||||||
|
|
||||||
|
|
||||||
@ -147,6 +149,7 @@ class NewStateModalForm(BaseModalForm):
|
|||||||
|
|
||||||
def save(self, is_before_state: bool = False):
|
def save(self, is_before_state: bool = False):
|
||||||
state = self.instance.add_state(self, is_before_state)
|
state = self.instance.add_state(self, is_before_state)
|
||||||
|
self.instance.mark_as_edited(self.user, self.request, ADDED_COMPENSATION_STATE)
|
||||||
return state
|
return state
|
||||||
|
|
||||||
def process_request(self, request: HttpRequest, msg_success: str = _("Object removed"), msg_error: str = FORM_INVALID, redirect_url: str = None):
|
def process_request(self, request: HttpRequest, msg_success: str = _("Object removed"), msg_error: str = FORM_INVALID, redirect_url: str = None):
|
||||||
@ -249,7 +252,8 @@ class NewDeadlineModalForm(BaseModalForm):
|
|||||||
self.form_caption = _("Insert data for the new deadline")
|
self.form_caption = _("Insert data for the new deadline")
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
deadline = self.instance.add_new_deadline(self)
|
deadline = self.instance.add_deadline(self)
|
||||||
|
self.instance.mark_as_edited(self.user, self.request, ADDED_DEADLINE)
|
||||||
return deadline
|
return deadline
|
||||||
|
|
||||||
|
|
||||||
@ -325,7 +329,8 @@ class NewActionModalForm(BaseModalForm):
|
|||||||
self.form_caption = _("Insert data for the new action")
|
self.form_caption = _("Insert data for the new action")
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
action = self.instance.add_new_action(self)
|
action = self.instance.add_action(self)
|
||||||
|
self.instance.mark_as_edited(self.user, self.request, ADDED_COMPENSATION_ACTION)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import shutil
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.db.models import QuerySet, Sum
|
from django.db.models import QuerySet, Sum
|
||||||
|
from django.http import HttpRequest
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from compensation.managers import CompensationManager
|
from compensation.managers import CompensationManager
|
||||||
@ -45,7 +46,7 @@ class AbstractCompensation(BaseObject):
|
|||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
def add_new_deadline(self, form) -> Deadline:
|
def add_deadline(self, form) -> Deadline:
|
||||||
""" Adds a new deadline to the abstract compensation
|
""" Adds a new deadline to the abstract compensation
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -73,7 +74,7 @@ class AbstractCompensation(BaseObject):
|
|||||||
self.deadlines.add(deadline)
|
self.deadlines.add(deadline)
|
||||||
return deadline
|
return deadline
|
||||||
|
|
||||||
def add_new_action(self, form) -> CompensationAction:
|
def add_action(self, form) -> CompensationAction:
|
||||||
""" Adds a new action to the compensation
|
""" Adds a new action to the compensation
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -86,8 +87,6 @@ class AbstractCompensation(BaseObject):
|
|||||||
user = form.user
|
user = form.user
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
user_action = UserActionLogEntry.get_created_action(user)
|
user_action = UserActionLogEntry.get_created_action(user)
|
||||||
edited_action = UserActionLogEntry.get_edited_action(user, _("Added action"))
|
|
||||||
|
|
||||||
comp_action = CompensationAction.objects.create(
|
comp_action = CompensationAction.objects.create(
|
||||||
action_type=form_data["action_type"],
|
action_type=form_data["action_type"],
|
||||||
amount=form_data["amount"],
|
amount=form_data["amount"],
|
||||||
@ -95,9 +94,6 @@ class AbstractCompensation(BaseObject):
|
|||||||
comment=form_data["comment"],
|
comment=form_data["comment"],
|
||||||
created=user_action,
|
created=user_action,
|
||||||
)
|
)
|
||||||
self.modified = edited_action
|
|
||||||
self.save()
|
|
||||||
self.log.add(edited_action)
|
|
||||||
self.actions.add(comp_action)
|
self.actions.add(comp_action)
|
||||||
return comp_action
|
return comp_action
|
||||||
|
|
||||||
@ -112,13 +108,7 @@ class AbstractCompensation(BaseObject):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
form_data = form.cleaned_data
|
form_data = form.cleaned_data
|
||||||
user = form.user
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
user_action = UserActionLogEntry.get_edited_action(user, _("Added state"))
|
|
||||||
self.log.add(user_action)
|
|
||||||
self.modified = user_action
|
|
||||||
self.save()
|
|
||||||
|
|
||||||
state = CompensationState.objects.create(
|
state = CompensationState.objects.create(
|
||||||
biotope_type=form_data["biotope_type"],
|
biotope_type=form_data["biotope_type"],
|
||||||
surface=form_data["surface"],
|
surface=form_data["surface"],
|
||||||
@ -271,9 +261,17 @@ class Compensation(AbstractCompensation, CEFMixin, CoherenceMixin):
|
|||||||
)
|
)
|
||||||
return docs
|
return docs
|
||||||
|
|
||||||
def add_new_action(self, form) -> CompensationAction:
|
def mark_as_edited(self, user: User, request: HttpRequest = None, edit_comment: str = None):
|
||||||
super().add_new_action(form)
|
""" Performs internal logic for setting the recordedd/checked state of the related intervention
|
||||||
self.intervention.set_as_edited(form.user)
|
|
||||||
|
Args:
|
||||||
|
user (User): The performing user
|
||||||
|
request (HttpRequest): The performing request
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
self.intervention.mark_as_edited(user, request, edit_comment)
|
||||||
|
|
||||||
|
|
||||||
class CompensationDocument(AbstractDocument):
|
class CompensationDocument(AbstractDocument):
|
||||||
|
@ -246,7 +246,7 @@ def remove_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
comp = get_object_or_404(Compensation, id=id)
|
comp = get_object_or_404(Compensation, id=id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=comp, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=comp, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request=request,
|
request=request,
|
||||||
msg_success=_("Compensation removed"),
|
msg_success=_("Compensation removed"),
|
||||||
@ -267,7 +267,7 @@ def new_document_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
comp = get_object_or_404(Compensation, id=id)
|
comp = get_object_or_404(Compensation, id=id)
|
||||||
form = NewCompensationDocumentForm(request.POST or None, request.FILES or None, instance=comp, user=request.user)
|
form = NewCompensationDocumentForm(request.POST or None, request.FILES or None, instance=comp, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Document added")
|
msg_success=_("Document added")
|
||||||
@ -336,7 +336,7 @@ def state_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
comp = get_object_or_404(Compensation, id=id)
|
comp = get_object_or_404(Compensation, id=id)
|
||||||
form = NewStateModalForm(request.POST or None, instance=comp, user=request.user)
|
form = NewStateModalForm(request.POST or None, instance=comp, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("State added")
|
msg_success=_("State added")
|
||||||
@ -357,7 +357,7 @@ def action_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
comp = get_object_or_404(Compensation, id=id)
|
comp = get_object_or_404(Compensation, id=id)
|
||||||
form = NewActionModalForm(request.POST or None, instance=comp, user=request.user)
|
form = NewActionModalForm(request.POST or None, instance=comp, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Action added")
|
msg_success=_("Action added")
|
||||||
@ -378,7 +378,7 @@ def deadline_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
comp = get_object_or_404(Compensation, id=id)
|
comp = get_object_or_404(Compensation, id=id)
|
||||||
form = NewDeadlineModalForm(request.POST or None, instance=comp, user=request.user)
|
form = NewDeadlineModalForm(request.POST or None, instance=comp, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Deadline added")
|
msg_success=_("Deadline added")
|
||||||
@ -400,7 +400,7 @@ def state_remove_view(request: HttpRequest, id: str, state_id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
state = get_object_or_404(CompensationState, id=state_id)
|
state = get_object_or_404(CompensationState, id=state_id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=state, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=state, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("State removed")
|
msg_success=_("State removed")
|
||||||
@ -422,7 +422,7 @@ def action_remove_view(request: HttpRequest, id: str, action_id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
action = get_object_or_404(CompensationAction, id=action_id)
|
action = get_object_or_404(CompensationAction, id=action_id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=action, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=action, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Action removed")
|
msg_success=_("Action removed")
|
||||||
|
@ -250,7 +250,7 @@ def remove_view(request: HttpRequest, id: str):
|
|||||||
messages.info(request, CANCEL_ACC_RECORDED_OR_DEDUCTED)
|
messages.info(request, CANCEL_ACC_RECORDED_OR_DEDUCTED)
|
||||||
return redirect("compensation:acc-detail", id=id)
|
return redirect("compensation:acc-detail", id=id)
|
||||||
|
|
||||||
form = RemoveModalForm(request.POST or None, instance=acc, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=acc, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request=request,
|
request=request,
|
||||||
msg_success=_("Eco-account removed"),
|
msg_success=_("Eco-account removed"),
|
||||||
@ -278,7 +278,7 @@ def deduction_remove_view(request: HttpRequest, id: str, deduction_id: str):
|
|||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
raise Http404("Unknown deduction")
|
raise Http404("Unknown deduction")
|
||||||
|
|
||||||
form = RemoveModalForm(request.POST or None, instance=eco_deduction, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=eco_deduction, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request=request,
|
request=request,
|
||||||
msg_success=_("Deduction removed")
|
msg_success=_("Deduction removed")
|
||||||
@ -325,7 +325,7 @@ def record_view(request: HttpRequest, id:str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
acc = get_object_or_404(EcoAccount, id=id)
|
acc = get_object_or_404(EcoAccount, id=id)
|
||||||
form = RecordModalForm(request.POST or None, instance=acc, user=request.user)
|
form = RecordModalForm(request.POST or None, instance=acc, request=request)
|
||||||
msg_succ = _("{} unrecorded") if acc.recorded else _("{} recorded")
|
msg_succ = _("{} unrecorded") if acc.recorded else _("{} recorded")
|
||||||
msg_succ = msg_succ.format(acc.identifier)
|
msg_succ = msg_succ.format(acc.identifier)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
@ -348,7 +348,7 @@ def state_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
acc = get_object_or_404(EcoAccount, id=id)
|
acc = get_object_or_404(EcoAccount, id=id)
|
||||||
form = NewStateModalForm(request.POST or None, instance=acc, user=request.user)
|
form = NewStateModalForm(request.POST or None, instance=acc, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("State added")
|
msg_success=_("State added")
|
||||||
@ -369,7 +369,7 @@ def action_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
acc = get_object_or_404(EcoAccount, id=id)
|
acc = get_object_or_404(EcoAccount, id=id)
|
||||||
form = NewActionModalForm(request.POST or None, instance=acc, user=request.user)
|
form = NewActionModalForm(request.POST or None, instance=acc, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Action added")
|
msg_success=_("Action added")
|
||||||
@ -391,7 +391,7 @@ def state_remove_view(request: HttpRequest, id: str, state_id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
state = get_object_or_404(CompensationState, id=state_id)
|
state = get_object_or_404(CompensationState, id=state_id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=state, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=state, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("State removed")
|
msg_success=_("State removed")
|
||||||
@ -413,7 +413,7 @@ def action_remove_view(request: HttpRequest, id: str, action_id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
action = get_object_or_404(CompensationAction, id=action_id)
|
action = get_object_or_404(CompensationAction, id=action_id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=action, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=action, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Action removed")
|
msg_success=_("Action removed")
|
||||||
@ -434,7 +434,7 @@ def deadline_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
acc = get_object_or_404(EcoAccount, id=id)
|
acc = get_object_or_404(EcoAccount, id=id)
|
||||||
form = NewDeadlineModalForm(request.POST or None, instance=acc, user=request.user)
|
form = NewDeadlineModalForm(request.POST or None, instance=acc, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Deadline added")
|
msg_success=_("Deadline added")
|
||||||
@ -454,7 +454,7 @@ def new_document_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
acc = get_object_or_404(EcoAccount, id=id)
|
acc = get_object_or_404(EcoAccount, id=id)
|
||||||
form = NewEcoAccountDocumentForm(request.POST or None, request.FILES or None, instance=acc, user=request.user)
|
form = NewEcoAccountDocumentForm(request.POST or None, request.FILES or None, instance=acc, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Document added")
|
msg_success=_("Document added")
|
||||||
@ -524,7 +524,7 @@ def new_deduction_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
acc = get_object_or_404(EcoAccount, id=id)
|
acc = get_object_or_404(EcoAccount, id=id)
|
||||||
form = NewDeductionModalForm(request.POST or None, instance=acc, user=request.user)
|
form = NewDeductionModalForm(request.POST or None, instance=acc, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Deduction added")
|
msg_success=_("Deduction added")
|
||||||
|
@ -30,7 +30,7 @@ def new_payment_view(request: HttpRequest, intervention_id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
intervention = get_object_or_404(Intervention, id=intervention_id)
|
intervention = get_object_or_404(Intervention, id=intervention_id)
|
||||||
form = NewPaymentForm(request.POST or None, instance=intervention, user=request.user)
|
form = NewPaymentForm(request.POST or None, instance=intervention, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Payment added")
|
msg_success=_("Payment added")
|
||||||
@ -50,7 +50,7 @@ def payment_remove_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
payment = get_object_or_404(Payment, id=id)
|
payment = get_object_or_404(Payment, id=id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=payment, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=payment, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request=request,
|
request=request,
|
||||||
msg_success=_("Payment removed"),
|
msg_success=_("Payment removed"),
|
||||||
|
18
ema/views.py
18
ema/views.py
@ -237,7 +237,7 @@ def remove_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
ema = get_object_or_404(Ema, id=id)
|
ema = get_object_or_404(Ema, id=id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=ema, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=ema, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request=request,
|
request=request,
|
||||||
msg_success=_("EMA removed"),
|
msg_success=_("EMA removed"),
|
||||||
@ -260,7 +260,7 @@ def record_view(request: HttpRequest, id: str):
|
|||||||
"""
|
"""
|
||||||
ema = get_object_or_404(Ema, id=id)
|
ema = get_object_or_404(Ema, id=id)
|
||||||
msg_succ = _("{} unrecorded") if ema.recorded else _("{} recorded")
|
msg_succ = _("{} unrecorded") if ema.recorded else _("{} recorded")
|
||||||
form = RecordModalForm(request.POST or None, instance=ema, user=request.user)
|
form = RecordModalForm(request.POST or None, instance=ema, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request=request,
|
request=request,
|
||||||
msg_success=msg_succ.format("EMA"),
|
msg_success=msg_succ.format("EMA"),
|
||||||
@ -281,7 +281,7 @@ def state_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
ema = get_object_or_404(Ema, id=id)
|
ema = get_object_or_404(Ema, id=id)
|
||||||
form = NewStateModalForm(request.POST or None, instance=ema, user=request.user)
|
form = NewStateModalForm(request.POST or None, instance=ema, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("State added")
|
msg_success=_("State added")
|
||||||
@ -302,7 +302,7 @@ def action_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
ema = get_object_or_404(Ema, id=id)
|
ema = get_object_or_404(Ema, id=id)
|
||||||
form = NewActionModalForm(request.POST or None, instance=ema, user=request.user)
|
form = NewActionModalForm(request.POST or None, instance=ema, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Action added")
|
msg_success=_("Action added")
|
||||||
@ -323,7 +323,7 @@ def deadline_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
ema = get_object_or_404(Ema, id=id)
|
ema = get_object_or_404(Ema, id=id)
|
||||||
form = NewDeadlineModalForm(request.POST or None, instance=ema, user=request.user)
|
form = NewDeadlineModalForm(request.POST or None, instance=ema, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Deadline added")
|
msg_success=_("Deadline added")
|
||||||
@ -343,7 +343,7 @@ def document_new_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
ema = get_object_or_404(Ema, id=id)
|
ema = get_object_or_404(Ema, id=id)
|
||||||
form = NewEmaDocumentForm(request.POST or None, request.FILES or None, instance=ema, user=request.user)
|
form = NewEmaDocumentForm(request.POST or None, request.FILES or None, instance=ema, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Document added")
|
msg_success=_("Document added")
|
||||||
@ -413,7 +413,7 @@ def state_remove_view(request: HttpRequest, id: str, state_id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
state = get_object_or_404(CompensationState, id=state_id)
|
state = get_object_or_404(CompensationState, id=state_id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=state, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=state, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("State removed")
|
msg_success=_("State removed")
|
||||||
@ -435,7 +435,7 @@ def action_remove_view(request: HttpRequest, id: str, action_id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
action = get_object_or_404(CompensationAction, id=action_id)
|
action = get_object_or_404(CompensationAction, id=action_id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=action, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=action, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Action removed")
|
msg_success=_("Action removed")
|
||||||
@ -463,7 +463,7 @@ def report_view(request:HttpRequest, id: str):
|
|||||||
|
|
||||||
# Prepare data for map viewer
|
# Prepare data for map viewer
|
||||||
geom_form = SimpleGeomForm(
|
geom_form = SimpleGeomForm(
|
||||||
instance=ema
|
instance=ema,
|
||||||
)
|
)
|
||||||
qrcode_img = generate_qr_code(
|
qrcode_img = generate_qr_code(
|
||||||
request.build_absolute_uri(reverse("ema:report", args=(id,))),
|
request.build_absolute_uri(reverse("ema:report", args=(id,))),
|
||||||
|
@ -169,6 +169,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)
|
||||||
return revocation
|
return revocation
|
||||||
|
|
||||||
|
|
||||||
@ -332,6 +333,7 @@ class NewDeductionModalForm(BaseModalForm):
|
|||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
deduction = self.instance.add_deduction(self)
|
deduction = self.instance.add_deduction(self)
|
||||||
|
self.instance.mark_as_edited(self.user, self.request)
|
||||||
return deduction
|
return deduction
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import shutil
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.db.models import QuerySet
|
from django.db.models import QuerySet
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.http import HttpRequest
|
||||||
|
|
||||||
from compensation.models import EcoAccountDeduction
|
from compensation.models import EcoAccountDeduction
|
||||||
from intervention.managers import InterventionManager
|
from intervention.managers import InterventionManager
|
||||||
@ -139,8 +139,7 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
return revoc_docs, regular_docs
|
return revoc_docs, regular_docs
|
||||||
|
|
||||||
def set_unchecked(self):
|
def set_unchecked(self):
|
||||||
log_entry = super().set_unchecked()
|
super().set_unchecked()
|
||||||
self.add_log_entry_to_compensations(log_entry)
|
|
||||||
|
|
||||||
def set_checked(self, user: User) -> UserActionLogEntry:
|
def set_checked(self, user: User) -> UserActionLogEntry:
|
||||||
log_entry = super().set_checked(user)
|
log_entry = super().set_checked(user)
|
||||||
@ -183,8 +182,6 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
user = form.user
|
user = form.user
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
created_action = UserActionLogEntry.get_created_action(user)
|
created_action = UserActionLogEntry.get_created_action(user)
|
||||||
edited_action = UserActionLogEntry.get_edited_action(user, _("Added payment"))
|
|
||||||
|
|
||||||
pay = Payment.objects.create(
|
pay = Payment.objects.create(
|
||||||
created=created_action,
|
created=created_action,
|
||||||
amount=form_data.get("amount", -1),
|
amount=form_data.get("amount", -1),
|
||||||
@ -192,10 +189,6 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
comment=form_data.get("comment", None),
|
comment=form_data.get("comment", None),
|
||||||
intervention=self,
|
intervention=self,
|
||||||
)
|
)
|
||||||
self.log.add(edited_action)
|
|
||||||
self.modified = edited_action
|
|
||||||
self.save()
|
|
||||||
self.mark_as_edited(user)
|
|
||||||
return pay
|
return pay
|
||||||
|
|
||||||
def add_revocation(self, form):
|
def add_revocation(self, form):
|
||||||
@ -211,7 +204,6 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
user = form.user
|
user = form.user
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
created_action = UserActionLogEntry.get_created_action(user)
|
created_action = UserActionLogEntry.get_created_action(user)
|
||||||
edited_action = UserActionLogEntry.get_edited_action(user)
|
|
||||||
|
|
||||||
revocation = Revocation.objects.create(
|
revocation = Revocation.objects.create(
|
||||||
date=form_data["date"],
|
date=form_data["date"],
|
||||||
@ -219,9 +211,6 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
comment=form_data["comment"],
|
comment=form_data["comment"],
|
||||||
created=created_action,
|
created=created_action,
|
||||||
)
|
)
|
||||||
self.modified = edited_action
|
|
||||||
self.save()
|
|
||||||
self.log.add(edited_action)
|
|
||||||
|
|
||||||
if form_data["file"]:
|
if form_data["file"]:
|
||||||
RevocationDocument.objects.create(
|
RevocationDocument.objects.create(
|
||||||
@ -231,7 +220,6 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
file=form_data["file"],
|
file=form_data["file"],
|
||||||
instance=revocation
|
instance=revocation
|
||||||
)
|
)
|
||||||
self.mark_as_edited(user)
|
|
||||||
return revocation
|
return revocation
|
||||||
|
|
||||||
def add_deduction(self, form):
|
def add_deduction(self, form):
|
||||||
@ -247,24 +235,16 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
user = form.user
|
user = form.user
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
# Create log entry
|
|
||||||
user_action_edit = UserActionLogEntry.get_edited_action(user)
|
|
||||||
user_action_create = UserActionLogEntry.get_created_action(user)
|
user_action_create = UserActionLogEntry.get_created_action(user)
|
||||||
|
|
||||||
self.log.add(user_action_edit)
|
|
||||||
self.modified = user_action_edit
|
|
||||||
self.save()
|
|
||||||
|
|
||||||
deduction = EcoAccountDeduction.objects.create(
|
deduction = EcoAccountDeduction.objects.create(
|
||||||
intervention=self,
|
intervention=self,
|
||||||
account=form_data["account"],
|
account=form_data["account"],
|
||||||
surface=form_data["surface"],
|
surface=form_data["surface"],
|
||||||
created=user_action_create,
|
created=user_action_create,
|
||||||
)
|
)
|
||||||
self.mark_as_edited(user)
|
|
||||||
return deduction
|
return deduction
|
||||||
|
|
||||||
def mark_as_edited(self, performing_user: User):
|
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None):
|
||||||
""" In case the object or a related object changed, internal processes need to be started, such as
|
""" In case the object or a related object changed, internal processes need to be started, such as
|
||||||
unrecord and uncheck
|
unrecord and uncheck
|
||||||
|
|
||||||
@ -274,7 +254,12 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
super().mark_as_edited(performing_user)
|
user_action_edit = UserActionLogEntry.get_edited_action(performing_user, comment=edit_comment)
|
||||||
|
self.log.add(user_action_edit)
|
||||||
|
self.modified = user_action_edit
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
super().mark_as_edited(performing_user, request)
|
||||||
if self.checked:
|
if self.checked:
|
||||||
self.set_unchecked()
|
self.set_unchecked()
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ def new_document_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
intervention = get_object_or_404(Intervention, id=id)
|
intervention = get_object_or_404(Intervention, id=id)
|
||||||
form = NewInterventionDocumentForm(request.POST or None, request.FILES or None, instance=intervention, user=request.user)
|
form = NewInterventionDocumentForm(request.POST or None, request.FILES or None, instance=intervention, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Document added")
|
msg_success=_("Document added")
|
||||||
@ -233,7 +233,7 @@ def detail_view(request: HttpRequest, id: str):
|
|||||||
is_data_shared = intervention.is_shared_with(user=_user)
|
is_data_shared = intervention.is_shared_with(user=_user)
|
||||||
|
|
||||||
geom_form = SimpleGeomForm(
|
geom_form = SimpleGeomForm(
|
||||||
instance=intervention
|
instance=intervention,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Inform user about revocation
|
# Inform user about revocation
|
||||||
@ -320,7 +320,7 @@ def remove_view(request: HttpRequest, id: str):
|
|||||||
"""
|
"""
|
||||||
obj = Intervention.objects.get(id=id)
|
obj = Intervention.objects.get(id=id)
|
||||||
identifier = obj.identifier
|
identifier = obj.identifier
|
||||||
form = RemoveModalForm(request.POST or None, instance=obj, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=obj, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
_("{} removed").format(identifier),
|
_("{} removed").format(identifier),
|
||||||
@ -341,7 +341,7 @@ def remove_revocation_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
obj = Revocation.objects.get(id=id)
|
obj = Revocation.objects.get(id=id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=obj, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=obj, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
_("Revocation removed"),
|
_("Revocation removed"),
|
||||||
@ -402,7 +402,7 @@ def create_share_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
intervention = get_object_or_404(Intervention, id=id)
|
intervention = get_object_or_404(Intervention, id=id)
|
||||||
form = ShareModalForm(request.POST or None, instance=intervention, request=request, user=request.user)
|
form = ShareModalForm(request.POST or None, instance=intervention, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Share settings updated")
|
msg_success=_("Share settings updated")
|
||||||
@ -423,7 +423,7 @@ def check_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
intervention = get_object_or_404(Intervention, id=id)
|
intervention = get_object_or_404(Intervention, id=id)
|
||||||
form = CheckModalForm(request.POST or None, instance=intervention, user=request.user)
|
form = CheckModalForm(request.POST or None, instance=intervention, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Check performed"),
|
msg_success=_("Check performed"),
|
||||||
@ -445,7 +445,7 @@ def new_revocation_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
intervention = get_object_or_404(Intervention, id=id)
|
intervention = get_object_or_404(Intervention, id=id)
|
||||||
form = NewRevocationModalForm(request.POST or None, request.FILES or None, instance=intervention, user=request.user)
|
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")
|
||||||
@ -492,7 +492,7 @@ def new_deduction_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
intervention = get_object_or_404(Intervention, id=id)
|
intervention = get_object_or_404(Intervention, id=id)
|
||||||
form = NewDeductionModalForm(request.POST or None, instance=intervention, user=request.user)
|
form = NewDeductionModalForm(request.POST or None, instance=intervention, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Deduction added")
|
msg_success=_("Deduction added")
|
||||||
@ -513,7 +513,7 @@ def record_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
intervention = get_object_or_404(Intervention, id=id)
|
intervention = get_object_or_404(Intervention, id=id)
|
||||||
form = RecordModalForm(request.POST or None, instance=intervention, user=request.user)
|
form = RecordModalForm(request.POST or None, instance=intervention, request=request)
|
||||||
msg_succ = _("{} unrecorded") if intervention.recorded else _("{} recorded")
|
msg_succ = _("{} unrecorded") if intervention.recorded else _("{} recorded")
|
||||||
msg_succ = msg_succ.format(intervention.identifier)
|
msg_succ = msg_succ.format(intervention.identifier)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
|
@ -14,11 +14,10 @@ from django import forms
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.gis.forms import OSMWidget, MultiPolygonField
|
from django.contrib.gis.forms import OSMWidget, MultiPolygonField
|
||||||
from django.contrib.gis.geos import Polygon, MultiPolygon
|
from django.contrib.gis.geos import MultiPolygon
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.http import HttpRequest, HttpResponseRedirect
|
from django.http import HttpRequest, HttpResponseRedirect
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.utils import timezone
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from konova.contexts import BaseContext
|
from konova.contexts import BaseContext
|
||||||
@ -39,15 +38,16 @@ class BaseForm(forms.Form):
|
|||||||
cancel_redirect = None
|
cancel_redirect = None
|
||||||
form_caption = None
|
form_caption = None
|
||||||
instance = None # The data holding model object
|
instance = None # The data holding model object
|
||||||
|
request = None
|
||||||
form_attrs = {} # Holds additional attributes, that can be used in the template
|
form_attrs = {} # Holds additional attributes, that can be used in the template
|
||||||
has_required_fields = False # Automatically set. Triggers hint rendering in templates
|
has_required_fields = False # Automatically set. Triggers hint rendering in templates
|
||||||
show_cancel_btn = True
|
show_cancel_btn = True
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.instance = kwargs.pop("instance", None)
|
self.instance = kwargs.pop("instance", None)
|
||||||
self.user = kwargs.pop("user", None)
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
if self.request is not None:
|
||||||
|
self.user = self.request.user
|
||||||
# Check for required fields
|
# Check for required fields
|
||||||
for _field_name, _field_val in self.fields.items():
|
for _field_name, _field_val in self.fields.items():
|
||||||
if _field_val.required:
|
if _field_val.required:
|
||||||
|
@ -8,9 +8,10 @@ Created on: 15.11.21
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from django.contrib import messages
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.utils import timezone
|
from django.http import HttpRequest
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from compensation.settings import COMPENSATION_IDENTIFIER_TEMPLATE, COMPENSATION_IDENTIFIER_LENGTH, \
|
from compensation.settings import COMPENSATION_IDENTIFIER_TEMPLATE, COMPENSATION_IDENTIFIER_LENGTH, \
|
||||||
@ -19,6 +20,7 @@ from ema.settings import EMA_ACCOUNT_IDENTIFIER_LENGTH, EMA_ACCOUNT_IDENTIFIER_T
|
|||||||
from intervention.settings import INTERVENTION_IDENTIFIER_LENGTH, INTERVENTION_IDENTIFIER_TEMPLATE
|
from intervention.settings import INTERVENTION_IDENTIFIER_LENGTH, INTERVENTION_IDENTIFIER_TEMPLATE
|
||||||
from konova.utils import generators
|
from konova.utils import generators
|
||||||
from konova.utils.generators import generate_random_string
|
from konova.utils.generators import generate_random_string
|
||||||
|
from konova.utils.message_templates import CHECKED_RECORDED_RESET
|
||||||
from user.models import UserActionLogEntry, UserAction
|
from user.models import UserActionLogEntry, UserAction
|
||||||
|
|
||||||
|
|
||||||
@ -228,7 +230,7 @@ class RecordableObjectMixin(models.Model):
|
|||||||
self.log.add(action)
|
self.log.add(action)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
def mark_as_edited(self, performing_user: User):
|
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None):
|
||||||
""" In case the object or a related object changed, internal processes need to be started, such as
|
""" In case the object or a related object changed, internal processes need to be started, such as
|
||||||
unrecord and uncheck
|
unrecord and uncheck
|
||||||
|
|
||||||
@ -238,9 +240,18 @@ class RecordableObjectMixin(models.Model):
|
|||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
action = UserActionLogEntry.get_edited_action(performing_user, edit_comment)
|
||||||
|
self.modified = action
|
||||||
|
self.log.add(action)
|
||||||
|
self.save()
|
||||||
|
|
||||||
if self.recorded:
|
if self.recorded:
|
||||||
self.set_unrecorded(performing_user)
|
self.set_unrecorded(performing_user)
|
||||||
|
if request:
|
||||||
|
messages.info(
|
||||||
|
request,
|
||||||
|
CHECKED_RECORDED_RESET
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CheckableObjectMixin(models.Model):
|
class CheckableObjectMixin(models.Model):
|
||||||
|
@ -46,7 +46,7 @@ def remove_document(request: HttpRequest, doc: AbstractDocument):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
title = doc.title
|
title = doc.title
|
||||||
form = RemoveModalForm(request.POST or None, instance=doc, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=doc, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request=request,
|
request=request,
|
||||||
msg_success=_("Document '{}' deleted").format(title)
|
msg_success=_("Document '{}' deleted").format(title)
|
||||||
|
@ -19,4 +19,10 @@ MISSING_GROUP_PERMISSION = _("You need to be part of another user group.")
|
|||||||
CHECKED_RECORDED_RESET = _("Status of Checked and Recorded reseted")
|
CHECKED_RECORDED_RESET = _("Status of Checked and Recorded reseted")
|
||||||
|
|
||||||
# ECO ACCOUNT
|
# ECO ACCOUNT
|
||||||
CANCEL_ACC_RECORDED_OR_DEDUCTED = _("Action canceled. Eco account is recorded or deductions exist. Only conservation office member can perform this action.")
|
CANCEL_ACC_RECORDED_OR_DEDUCTED = _("Action canceled. Eco account is recorded or deductions exist. Only conservation office member can perform this action.")
|
||||||
|
|
||||||
|
# Edited
|
||||||
|
EDITED_GENERAL_DATA = _("Edited general data")
|
||||||
|
ADDED_COMPENSATION_STATE = _("Added compensation state")
|
||||||
|
ADDED_DEADLINE = _("Added deadline")
|
||||||
|
ADDED_COMPENSATION_ACTION = _("Added compensation action")
|
@ -109,7 +109,7 @@ def remove_deadline_view(request: HttpRequest, id:str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
deadline = get_object_or_404(Deadline, id=id)
|
deadline = get_object_or_404(Deadline, id=id)
|
||||||
form = RemoveModalForm(request.POST or None, instance=deadline, user=request.user)
|
form = RemoveModalForm(request.POST or None, instance=deadline, request=request)
|
||||||
return form.process_request(
|
return form.process_request(
|
||||||
request,
|
request,
|
||||||
msg_success=_("Deadline removed")
|
msg_success=_("Deadline removed")
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -83,7 +83,7 @@ def contact_view(request: HttpRequest, id: str):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
user = get_object_or_404(User, id=id)
|
user = get_object_or_404(User, id=id)
|
||||||
form = UserContactForm(request.POST or None, instance=user, user=request.user)
|
form = UserContactForm(request.POST or None, instance=user, request=request)
|
||||||
template = "modal/modal_form.html"
|
template = "modal/modal_form.html"
|
||||||
context = {
|
context = {
|
||||||
"form": form,
|
"form": form,
|
||||||
|
Loading…
Reference in New Issue
Block a user