From 328c030cc40c859fd7033503aebbdec504c99a81 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Tue, 3 Jul 2018 21:38:10 +0200 Subject: [PATCH] Supprime la vue 'recharge' qui faisait doublon avec 'credit_solde' --- .../templates/cotisations/facture.html | 7 ++- cotisations/urls.py | 5 -- cotisations/views.py | 50 ++++--------------- users/templates/users/profil.html | 4 +- 4 files changed, 19 insertions(+), 47 deletions(-) diff --git a/cotisations/templates/cotisations/facture.html b/cotisations/templates/cotisations/facture.html index 082759c4..03a4225b 100644 --- a/cotisations/templates/cotisations/facture.html +++ b/cotisations/templates/cotisations/facture.html @@ -31,7 +31,12 @@ with this program; if not, write to the Free Software Foundation, Inc., {% block content %} {% bootstrap_form_errors factureform %} - +{% if title %} +

{{title}}

+{% endif %} +{% if balance %} +

{% trans "Current balance :" %}{{balance}}€

+{% endif %}
{% csrf_token %} {% if articlesformset %} diff --git a/cotisations/urls.py b/cotisations/urls.py index 9e318b53..ce6aa0f4 100644 --- a/cotisations/urls.py +++ b/cotisations/urls.py @@ -138,11 +138,6 @@ urlpatterns = [ views.new_facture_solde, name='new_facture_solde' ), - url( - r'^recharge/$', - views.recharge, - name='recharge' - ), url(r'^$', views.index, name='index'), ] + payment_methods.urls.urlpatterns diff --git a/cotisations/views.py b/cotisations/views.py index 79d989e5..bb391d13 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -326,39 +326,6 @@ def del_facture(request, facture, **_kwargs): }, 'cotisations/delete.html', request) -# TODO : change solde to balance -@login_required -@can_create(Facture) -@can_edit(User) -def credit_solde(request, user, **_kwargs): - """ - View used to edit the balance of a user. - Can be use either to increase or decrease a user's balance. - """ - # TODO : change facture to invoice - invoice = CreditSoldeForm(request.POST or None) - if invoice.is_valid(): - invoice_instance = invoice.save(commit=False) - invoice_instance.user = user - invoice_instance.save() - new_purchase = Vente.objects.create( - facture=invoice_instance, - name="solde", - prix=invoice.cleaned_data['montant'], - number=1 - ) - new_purchase.save() - messages.success( - request, - _("Balance successfully updated.") - ) - return redirect(reverse('cotisations:index')) - return form({ - 'factureform': invoice, - 'action_name': _("Edit") - }, 'cotisations/facture.html', request) - - @login_required @can_create(Article) def add_article(request): @@ -815,11 +782,14 @@ def new_facture_solde(request, userid): }, 'cotisations/new_facture_solde.html', request) -# TODO : change recharge to refill +# TODO : change solde to balance @login_required -def recharge(request): +@can_create(Facture) +@can_edit(User) +def credit_solde(request, user, **_kwargs): """ - View used to refill the balance by using online payment. + View used to edit the balance of a user. + Can be use either to increase or decrease a user's balance. """ refill_form = RechargeForm(request.POST or None, user=request.user) if refill_form.is_valid(): @@ -835,6 +805,8 @@ def recharge(request): ) return invoice.paiement.end_payment(invoice, request) return form({ - 'rechargeform': refill_form, - 'solde': request.user.solde - }, 'cotisations/recharge.html', request) + 'factureform': refill_form, + 'balance': request.user.solde, + 'title': _("Refill your balance"), + 'action_name': _("Pay") + }, 'cotisations/facture.html', request) diff --git a/users/templates/users/profil.html b/users/templates/users/profil.html index 00390fdd..4b50cc99 100644 --- a/users/templates/users/profil.html +++ b/users/templates/users/profil.html @@ -34,7 +34,7 @@ non adhérent{% endif %} et votre connexion est {% if users.has_access %} active{% else %}désactivée{% endif %}.

{% if user_solde %}

Votre solde est de {{ users.solde }}€. - + Recharger @@ -165,7 +165,7 @@ non adhérent{% endif %} et votre connexion est {% if users.has_access %} Solde {{ users.solde }} € {% if user_solde %} - + Recharger