Restore payment edit form for volunteers
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
64b91cf7e0
commit
bc535f4075
|
@ -134,7 +134,7 @@
|
|||
</dt>
|
||||
<dd class="col-sm-6">
|
||||
Valide : {{ payment.valid|yesno }}
|
||||
{% if payment.valid is False %}
|
||||
{% if payment.valid is False or user.registration.is_volunteer %}
|
||||
{% if user.registration in payment.registrations.all or user.registration.is_coach or user.registration.is_volunteer %}
|
||||
<a href="{% url "registration:update_payment" pk=payment.pk %}" class="btn btn-secondary">
|
||||
<i class="fas fa-money-bill-wave"></i> {% trans "Update payment" %}
|
||||
|
|
|
@ -611,7 +611,7 @@ class Payment(models.Model):
|
|||
base_site = "https://" + Site.objects.first().domain
|
||||
checkout_intent = helloasso.create_checkout_intent(
|
||||
amount=100 * self.amount,
|
||||
name=f"Participation au TFJM² {year} - {tournament.name}",
|
||||
name=f"Participation au TFJM² {year} - {tournament.name} - {self.team.trigram}",
|
||||
back_url=base_site + reverse('registration:update_payment', args=(self.id,)),
|
||||
error_url=f"{base_site}{reverse('registration:payment_hello_asso_return', args=(self.id,))}?type=error",
|
||||
return_url=f"{base_site}{reverse('registration:payment_hello_asso_return', args=(self.id,))}?type=return",
|
||||
|
|
|
@ -198,6 +198,14 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div id="form-content">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
</div>
|
||||
<button class="btn btn-primary" type="submit">{% trans "Update" %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endblock content %}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@
|
|||
{% else %}
|
||||
{{ payment.get_type_display }}, {% trans "valid:" %} {{ payment.valid|yesno:yesnodefault }}
|
||||
{% endif %}
|
||||
{% if user.registration.is_admin or payment.valid is False %}
|
||||
{% if user.registration.is_volunteer or payment.valid is False %}
|
||||
<a href="{% url "registration:update_payment" pk=payment.pk %}" class="btn btn-secondary">
|
||||
<i class="fas fa-money-bill-wave"></i> {% trans "Update payment" %}
|
||||
</a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright (C) 2020 by Animath
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from tempfile import mkdtemp
|
||||
|
@ -482,7 +482,7 @@ class PaymentUpdateView(LoginRequiredMixin, UpdateView):
|
|||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse_lazy("registration:user_detail", args=(self.object.registrations.first().user.pk,))
|
||||
return reverse_lazy("participation:team_detail", args=(self.object.registrations.first().team.pk,))
|
||||
|
||||
|
||||
class PaymentUpdateGroupView(LoginRequiredMixin, DetailView):
|
||||
|
@ -594,7 +594,7 @@ class PaymentHelloAssoReturnView(DetailView):
|
|||
or (request.user.registration.is_coach and request.user.registration.team == team))
|
||||
|
||||
if right_to_see:
|
||||
error_response = redirect("registration:update_payment", args=(payment.pk,))
|
||||
error_response = redirect("registration:update_payment", pk=payment.pk)
|
||||
else:
|
||||
error_response = redirect("index")
|
||||
|
||||
|
@ -617,11 +617,14 @@ class PaymentHelloAssoReturnView(DetailView):
|
|||
|
||||
checkout_intent = payment.get_checkout_intent()
|
||||
if 'order' in checkout_intent:
|
||||
payment.type = "helloasso"
|
||||
payment.valid = True
|
||||
payment.additional_information = json.dumps(checkout_intent['order'])
|
||||
payment.save()
|
||||
messages.success(request, _("The payment has been successfully validated! "
|
||||
"Your registration is now complete."))
|
||||
else:
|
||||
payment.type = "helloasso"
|
||||
payment.valid = None
|
||||
payment.save()
|
||||
messages.success(request, _("Your payment is done! "
|
||||
|
@ -629,14 +632,10 @@ class PaymentHelloAssoReturnView(DetailView):
|
|||
"and will be automatically done. "
|
||||
"If it is not the case, please contact us."))
|
||||
|
||||
if not request.user.is_anonymous and request.user.registration in payment.registrations.all():
|
||||
success_response = redirect("registration:user_detail", args=(request.user.pk,))
|
||||
elif right_to_see:
|
||||
success_response = redirect("participation:team_detail", args=(team.pk,))
|
||||
if right_to_see:
|
||||
return redirect("participation:team_detail", pk=team.pk)
|
||||
else:
|
||||
success_response = redirect("index")
|
||||
|
||||
return success_response
|
||||
return redirect("index")
|
||||
|
||||
|
||||
class PhotoAuthorizationView(LoginRequiredMixin, View):
|
||||
|
|
Loading…
Reference in New Issue