Withdraw to deduct
* refactors all files and variable names * WIP: Models and attributes
This commit is contained in:
@@ -16,7 +16,7 @@ from django.shortcuts import render, get_object_or_404
|
||||
from compensation.forms import NewStateModalForm, NewActionModalForm, NewDeadlineModalForm
|
||||
from compensation.models import EcoAccount
|
||||
from compensation.tables import EcoAccountTable
|
||||
from intervention.forms import NewWithdrawForm
|
||||
from intervention.forms import NewDeductionForm
|
||||
from konova.contexts import BaseContext
|
||||
from konova.decorators import any_group_check, default_group_required, conservation_office_group_required
|
||||
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentForm, RecordModalForm
|
||||
@@ -94,10 +94,10 @@ def open_view(request: HttpRequest, id: str):
|
||||
sum_after_states = after_states.aggregate(Sum("surface"))["surface__sum"] or 0
|
||||
diff_states = abs(sum_before_states - sum_after_states)
|
||||
|
||||
# Calculate rest of available surface for withdraws
|
||||
# Calculate rest of available surface for deductions
|
||||
available = acc.get_available_rest(as_percentage=True)
|
||||
|
||||
withdraws = acc.withdraws.filter(
|
||||
deductions = acc.withdraws.filter(
|
||||
intervention__deleted=None,
|
||||
)
|
||||
|
||||
@@ -115,7 +115,7 @@ def open_view(request: HttpRequest, id: str):
|
||||
"is_zb_member": in_group(_user, ZB_GROUP),
|
||||
"is_ets_member": in_group(_user, ETS_GROUP),
|
||||
"LANIS_LINK": acc.get_LANIS_link(),
|
||||
"withdraws": withdraws,
|
||||
"deductions": deductions,
|
||||
}
|
||||
context = BaseContext(request, context).context
|
||||
return render(request, template, context)
|
||||
@@ -143,27 +143,27 @@ def remove_view(request: HttpRequest, id: str):
|
||||
|
||||
@login_required
|
||||
@default_group_required
|
||||
def withdraw_remove_view(request: HttpRequest, id: str, withdraw_id: str):
|
||||
""" Renders a modal view for removing withdraws
|
||||
def deduction_remove_view(request: HttpRequest, id: str, deduction_id: str):
|
||||
""" Renders a modal view for removing deductions
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The eco account's id
|
||||
withdraw_id (str): The withdraw's id
|
||||
deduction_id (str): The deduction's id
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
acc = get_object_or_404(EcoAccount, id=id)
|
||||
try:
|
||||
eco_withdraw = acc.withdraws.get(id=withdraw_id)
|
||||
eco_deduction = acc.withdraws.get(id=deduction_id)
|
||||
except ObjectDoesNotExist:
|
||||
raise Http404("Unknown withdraw")
|
||||
raise Http404("Unknown deduction")
|
||||
|
||||
form = RemoveModalForm(request.POST or None, instance=eco_withdraw, user=request.user)
|
||||
form = RemoveModalForm(request.POST or None, instance=eco_deduction, user=request.user)
|
||||
return form.process_request(
|
||||
request=request,
|
||||
msg_success=_("Withdraw removed")
|
||||
msg_success=_("Deduction removed")
|
||||
)
|
||||
|
||||
|
||||
@@ -291,19 +291,19 @@ def new_document_view(request: HttpRequest, id: str):
|
||||
|
||||
@login_required
|
||||
@default_group_required
|
||||
def new_withdraw_view(request: HttpRequest, id: str):
|
||||
""" Renders a modal form view for creating withdraws
|
||||
def new_deduction_view(request: HttpRequest, id: str):
|
||||
""" Renders a modal form view for creating deductions
|
||||
|
||||
Args:
|
||||
request ():
|
||||
id ():
|
||||
request (HttpRequest): THe incoming request
|
||||
id (str): The eco account's id
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
acc = get_object_or_404(EcoAccount, id=id)
|
||||
form = NewWithdrawForm(request.POST or None, instance=acc, user=request.user)
|
||||
form = NewDeductionForm(request.POST or None, instance=acc, user=request.user)
|
||||
return form.process_request(
|
||||
request,
|
||||
msg_success=_("Withdraw added")
|
||||
msg_success=_("Deduction added")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user