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>
|
</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
Valide : {{ payment.valid|yesno }}
|
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 %}
|
{% 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">
|
<a href="{% url "registration:update_payment" pk=payment.pk %}" class="btn btn-secondary">
|
||||||
<i class="fas fa-money-bill-wave"></i> {% trans "Update payment" %}
|
<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
|
base_site = "https://" + Site.objects.first().domain
|
||||||
checkout_intent = helloasso.create_checkout_intent(
|
checkout_intent = helloasso.create_checkout_intent(
|
||||||
amount=100 * self.amount,
|
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,)),
|
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",
|
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",
|
return_url=f"{base_site}{reverse('registration:payment_hello_asso_return', args=(self.id,))}?type=return",
|
||||||
|
|
|
@ -198,6 +198,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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 %}
|
{% endif %}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ payment.get_type_display }}, {% trans "valid:" %} {{ payment.valid|yesno:yesnodefault }}
|
{{ payment.get_type_display }}, {% trans "valid:" %} {{ payment.valid|yesno:yesnodefault }}
|
||||||
{% endif %}
|
{% 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">
|
<a href="{% url "registration:update_payment" pk=payment.pk %}" class="btn btn-secondary">
|
||||||
<i class="fas fa-money-bill-wave"></i> {% trans "Update payment" %}
|
<i class="fas fa-money-bill-wave"></i> {% trans "Update payment" %}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright (C) 2020 by Animath
|
# Copyright (C) 2020 by Animath
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
|
@ -482,7 +482,7 @@ class PaymentUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
def get_success_url(self):
|
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):
|
class PaymentUpdateGroupView(LoginRequiredMixin, DetailView):
|
||||||
|
@ -594,7 +594,7 @@ class PaymentHelloAssoReturnView(DetailView):
|
||||||
or (request.user.registration.is_coach and request.user.registration.team == team))
|
or (request.user.registration.is_coach and request.user.registration.team == team))
|
||||||
|
|
||||||
if right_to_see:
|
if right_to_see:
|
||||||
error_response = redirect("registration:update_payment", args=(payment.pk,))
|
error_response = redirect("registration:update_payment", pk=payment.pk)
|
||||||
else:
|
else:
|
||||||
error_response = redirect("index")
|
error_response = redirect("index")
|
||||||
|
|
||||||
|
@ -617,11 +617,14 @@ class PaymentHelloAssoReturnView(DetailView):
|
||||||
|
|
||||||
checkout_intent = payment.get_checkout_intent()
|
checkout_intent = payment.get_checkout_intent()
|
||||||
if 'order' in checkout_intent:
|
if 'order' in checkout_intent:
|
||||||
|
payment.type = "helloasso"
|
||||||
payment.valid = True
|
payment.valid = True
|
||||||
|
payment.additional_information = json.dumps(checkout_intent['order'])
|
||||||
payment.save()
|
payment.save()
|
||||||
messages.success(request, _("The payment has been successfully validated! "
|
messages.success(request, _("The payment has been successfully validated! "
|
||||||
"Your registration is now complete."))
|
"Your registration is now complete."))
|
||||||
else:
|
else:
|
||||||
|
payment.type = "helloasso"
|
||||||
payment.valid = None
|
payment.valid = None
|
||||||
payment.save()
|
payment.save()
|
||||||
messages.success(request, _("Your payment is done! "
|
messages.success(request, _("Your payment is done! "
|
||||||
|
@ -629,14 +632,10 @@ class PaymentHelloAssoReturnView(DetailView):
|
||||||
"and will be automatically done. "
|
"and will be automatically done. "
|
||||||
"If it is not the case, please contact us."))
|
"If it is not the case, please contact us."))
|
||||||
|
|
||||||
if not request.user.is_anonymous and request.user.registration in payment.registrations.all():
|
if right_to_see:
|
||||||
success_response = redirect("registration:user_detail", args=(request.user.pk,))
|
return redirect("participation:team_detail", pk=team.pk)
|
||||||
elif right_to_see:
|
|
||||||
success_response = redirect("participation:team_detail", args=(team.pk,))
|
|
||||||
else:
|
else:
|
||||||
success_response = redirect("index")
|
return redirect("index")
|
||||||
|
|
||||||
return success_response
|
|
||||||
|
|
||||||
|
|
||||||
class PhotoAuthorizationView(LoginRequiredMixin, View):
|
class PhotoAuthorizationView(LoginRequiredMixin, View):
|
||||||
|
|
Loading…
Reference in New Issue