From 337c8dd80b8fde516840afb8d89e605c37ba84f7 Mon Sep 17 00:00:00 2001 From: Hugo LEVY-FALK Date: Sun, 15 Jul 2018 14:58:04 +0200 Subject: [PATCH] =?UTF-8?q?Ajoute=20l'affichage=20du=20moyen=20de=20paieme?= =?UTF-8?q?nt=20personnalis=C3=A9=20dans=20la=20liste=20des=20paiements.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/migrations/0030_custom_payment.py | 3 +++ cotisations/models.py | 6 ++++++ cotisations/payment_methods/balance/models.py | 5 ++++- cotisations/payment_methods/cheque/models.py | 5 +++++ cotisations/payment_methods/comnpay/models.py | 4 ++++ cotisations/templates/cotisations/aff_paiement.html | 4 ++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cotisations/migrations/0030_custom_payment.py b/cotisations/migrations/0030_custom_payment.py index 847da608..6cf74f22 100644 --- a/cotisations/migrations/0030_custom_payment.py +++ b/cotisations/migrations/0030_custom_payment.py @@ -95,6 +95,7 @@ class Migration(migrations.Migration): ('payment', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='payment_method', to='cotisations.Paiement')), ], bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model), + options={'verbose_name': 'Cheque'}, ), migrations.CreateModel( name='ComnpayPayment', @@ -106,6 +107,7 @@ class Migration(migrations.Migration): ('minimum_payment', models.DecimalField(decimal_places=2, default=1, help_text='The minimal amount of money you have to use when paying with ComNpay', max_digits=5, verbose_name='Minimum payment')), ], bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model), + options={'verbose_name': 'ComNpay'}, ), migrations.CreateModel( name='BalancePayment', @@ -116,6 +118,7 @@ class Migration(migrations.Migration): ('maximum_balance', models.DecimalField(decimal_places=2, default=50, help_text='The maximal amount of money allowed for the balance.', max_digits=5, verbose_name='Maximum balance', null=True, blank=True)), ], bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model), + options={'verbose_name': 'User Balance'}, ), migrations.RunPython(add_comnpay), migrations.RunPython(add_cheque), diff --git a/cotisations/models.py b/cotisations/models.py index 8b6d5a8c..7b4fcab3 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -716,6 +716,12 @@ class Paiement(RevMixin, AclMixin, models.Model): return cls.objects.all() return cls.objects.filter(available_for_everyone=True) + def get_payment_method_name(self): + p = find_payment_method(self) + if p is not None: + return p._meta.verbose_name + return _("No custom payment method") + class Cotisation(RevMixin, AclMixin, models.Model): """ diff --git a/cotisations/payment_methods/balance/models.py b/cotisations/payment_methods/balance/models.py index 4a80fea7..8c328279 100644 --- a/cotisations/payment_methods/balance/models.py +++ b/cotisations/payment_methods/balance/models.py @@ -24,7 +24,6 @@ from django.urls import reverse from django.utils.translation import ugettext as _ from django.utils.translation import ugettext_lazy as _l from django.contrib import messages -from django.forms import ValidationError from cotisations.models import Paiement @@ -35,6 +34,10 @@ class BalancePayment(PaymentMethodMixin, models.Model): """ The model allowing you to pay with a cheque. """ + + class Meta: + verbose_name = _l("User Balance") + payment = models.OneToOneField( Paiement, on_delete=models.CASCADE, diff --git a/cotisations/payment_methods/cheque/models.py b/cotisations/payment_methods/cheque/models.py index bdb4e594..c2680e7a 100644 --- a/cotisations/payment_methods/cheque/models.py +++ b/cotisations/payment_methods/cheque/models.py @@ -21,6 +21,7 @@ from django.db import models from django.shortcuts import redirect from django.urls import reverse +from django.utils.translation import ugettext_lazy as _l from cotisations.models import Paiement from cotisations.payment_methods.mixins import PaymentMethodMixin @@ -30,6 +31,10 @@ class ChequePayment(PaymentMethodMixin, models.Model): """ The model allowing you to pay with a cheque. """ + + class Meta: + verbose_name = _l("Cheque") + payment = models.OneToOneField( Paiement, on_delete=models.CASCADE, diff --git a/cotisations/payment_methods/comnpay/models.py b/cotisations/payment_methods/comnpay/models.py index 0801df3b..ff6fed0d 100644 --- a/cotisations/payment_methods/comnpay/models.py +++ b/cotisations/payment_methods/comnpay/models.py @@ -35,6 +35,10 @@ class ComnpayPayment(PaymentMethodMixin, models.Model): """ The model allowing you to pay with COMNPAY. """ + + class Meta: + verbose_name = "ComNpay" + payment = models.OneToOneField( Paiement, on_delete=models.CASCADE, diff --git a/cotisations/templates/cotisations/aff_paiement.html b/cotisations/templates/cotisations/aff_paiement.html index 91049a3f..e42d512f 100644 --- a/cotisations/templates/cotisations/aff_paiement.html +++ b/cotisations/templates/cotisations/aff_paiement.html @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% trans "Payment type" %} {% trans "Is available for everyone" %} + {% trans "Custom payment method" %} @@ -37,6 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ paiement.moyen }} {{ paiement.available_for_everyone }} + + {{paiement.get_payment_method_name}} + {% can_edit paiement %}