mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 17:42:24 +00:00
Grouping payments is only allowed if all members of a team have not paid yet
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
87038dd6f4
commit
295717256f
@ -24,6 +24,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
{% if can_group %}
|
||||||
{% if payment.grouped %}
|
{% if payment.grouped %}
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
You want finally that each member pays its own registration? Then click on the button:
|
You want finally that each member pays its own registration? Then click on the button:
|
||||||
@ -44,6 +45,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -459,6 +459,9 @@ class PaymentUpdateView(LoginRequiredMixin, UpdateView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data()
|
context = super().get_context_data()
|
||||||
context['title'] = _("Update payment")
|
context['title'] = _("Update payment")
|
||||||
|
# Grouping is only possible if there isn't any validated payment in the team
|
||||||
|
context['can_group'] = all(p.valid is False for reg in self.object.team.students.all()
|
||||||
|
for p in reg.payments.filter(valid=self.object.valid).all())
|
||||||
context['bank_transfer_form'] = PaymentForm(payment_type='bank_transfer',
|
context['bank_transfer_form'] = PaymentForm(payment_type='bank_transfer',
|
||||||
data=self.request.POST or None,
|
data=self.request.POST or None,
|
||||||
instance=self.object)
|
instance=self.object)
|
||||||
@ -489,11 +492,18 @@ class PaymentUpdateGroupView(LoginRequiredMixin, DetailView):
|
|||||||
model = Payment
|
model = Payment
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
payment = self.get_object()
|
||||||
|
|
||||||
if not self.request.user.is_authenticated or \
|
if not self.request.user.is_authenticated or \
|
||||||
not self.request.user.registration.is_admin \
|
not self.request.user.registration.is_admin \
|
||||||
and (self.request.user.registration not in self.get_object().registrations.all()
|
and (self.request.user.registration not in self.get_object().registrations.all()
|
||||||
or self.get_object().valid is not False):
|
or payment.valid is not False):
|
||||||
return self.handle_no_permission()
|
return self.handle_no_permission()
|
||||||
|
|
||||||
|
if any(p.valid is not False for reg in payment.team.students.all()
|
||||||
|
for p in reg.payments.filter(valid=payment.valid).all()):
|
||||||
|
raise PermissionDenied(_("Since one payment is already validated, or pending validation, "
|
||||||
|
"grouping is not possible."))
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user