mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-22 20:38:28 +02:00
Add payment information after payment
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -451,8 +451,7 @@ class PaymentUpdateView(LoginRequiredMixin, UpdateView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not self.request.user.is_authenticated or \
|
||||
not self.request.user.registration.is_admin \
|
||||
and (self.request.user.registration not in self.get_object().registrations.all()
|
||||
or self.get_object().valid is not False):
|
||||
and self.request.user.registration not in self.get_object().registrations.all():
|
||||
return self.handle_no_permission()
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
@ -477,8 +476,12 @@ class PaymentUpdateView(LoginRequiredMixin, UpdateView):
|
||||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
form.instance.valid = None
|
||||
old_instance = Payment.objects.get(pk=self.object.pk)
|
||||
if self.request.user.registration.participates:
|
||||
if old_instance.valid is not False:
|
||||
raise PermissionDenied(_("This payment is already valid or pending validation."))
|
||||
else:
|
||||
form.instance.valid = None
|
||||
if old_instance.receipt:
|
||||
old_instance.receipt.delete()
|
||||
old_instance.save()
|
||||
|
Reference in New Issue
Block a user