1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-02-24 23:01:20 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Emmy D'Anello
f9645b016a
Allow organizers to submit payment forms
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-02-29 23:05:41 +01:00
Emmy D'Anello
6b7b802d14
Don't update payment amount if there isn't anyone
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-02-29 23:00:35 +01:00
Emmy D'Anello
1684c079e3
Fix payment group permission
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-02-29 22:59:54 +01:00
2 changed files with 5 additions and 5 deletions

View File

@ -49,5 +49,5 @@ def update_payment_amount(instance, **_):
"""
if instance.type == 'free' or instance.type == 'scholarship':
instance.amount = 0
elif instance.pk:
elif instance.pk and instance.registrations.exists():
instance.amount = instance.registrations.count() * instance.tournament.price

View File

@ -460,7 +460,7 @@ class PaymentUpdateView(LoginRequiredMixin, UpdateView):
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())
for p in reg.payments.filter(final=self.object.final).all())
context['bank_transfer_form'] = PaymentForm(payment_type='bank_transfer',
data=self.request.POST or None,
instance=self.object)
@ -480,7 +480,7 @@ class PaymentUpdateView(LoginRequiredMixin, UpdateView):
if self.request.user.registration.participates:
if old_instance.valid is not False:
raise PermissionDenied(_("This payment is already valid or pending validation."))
else:
if old_instance.valid is False:
form.instance.valid = None
if old_instance.receipt:
old_instance.receipt.delete()
@ -504,7 +504,7 @@ class PaymentUpdateGroupView(LoginRequiredMixin, DetailView):
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()):
for p in reg.payments.filter(final=payment.final).all()):
raise PermissionDenied(_("Since one payment is already validated, or pending validation, "
"grouping is not possible."))
return super().dispatch(request, *args, **kwargs)