mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 06:22:22 +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,25 +24,27 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% if payment.grouped %}
|
{% if can_group %}
|
||||||
{% blocktrans trimmed %}
|
{% if payment.grouped %}
|
||||||
You want finally that each member pays its own registration? Then click on the button:
|
{% blocktrans trimmed %}
|
||||||
{% endblocktrans %}
|
You want finally that each member pays its own registration? Then click on the button:
|
||||||
<div class="text-center">
|
{% endblocktrans %}
|
||||||
<a href="{% url 'registration:update_payment_group_mode' pk=payment.pk %}" class="btn btn-warning">
|
<div class="text-center">
|
||||||
<i class="fas fa-user"></i> {% trans "Back to single payments" %}
|
<a href="{% url 'registration:update_payment_group_mode' pk=payment.pk %}" class="btn btn-warning">
|
||||||
</a>
|
<i class="fas fa-user"></i> {% trans "Back to single payments" %}
|
||||||
</div>
|
</a>
|
||||||
{% else %}
|
</div>
|
||||||
{% blocktrans trimmed %}
|
{% else %}
|
||||||
You want to pay for the registrations of all members of your team,
|
{% blocktrans trimmed %}
|
||||||
or your school will pay for all registrations? Then click on the button:
|
You want to pay for the registrations of all members of your team,
|
||||||
{% endblocktrans %}
|
or your school will pay for all registrations? Then click on the button:
|
||||||
<div class="text-center">
|
{% endblocktrans %}
|
||||||
<a href="{% url 'registration:update_payment_group_mode' pk=payment.pk %}" class="btn btn-warning">
|
<div class="text-center">
|
||||||
<i class="fas fa-users"></i> {% trans "Group the payments of my team" %}
|
<a href="{% url 'registration:update_payment_group_mode' pk=payment.pk %}" class="btn btn-warning">
|
||||||
</a>
|
<i class="fas fa-users"></i> {% trans "Group the payments of my team" %}
|
||||||
</div>
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -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