8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 19:33:11 +00:00

Ajoute l'affichage du moyen de paiement personnalisé dans la liste des paiements.

This commit is contained in:
Hugo LEVY-FALK 2018-07-15 14:58:04 +02:00
parent 0ceead7969
commit 337c8dd80b
6 changed files with 26 additions and 1 deletions

View file

@ -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')), ('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), bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model),
options={'verbose_name': 'Cheque'},
), ),
migrations.CreateModel( migrations.CreateModel(
name='ComnpayPayment', 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')), ('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), bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model),
options={'verbose_name': 'ComNpay'},
), ),
migrations.CreateModel( migrations.CreateModel(
name='BalancePayment', 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)), ('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), bases=(cotisations.payment_methods.mixins.PaymentMethodMixin, models.Model),
options={'verbose_name': 'User Balance'},
), ),
migrations.RunPython(add_comnpay), migrations.RunPython(add_comnpay),
migrations.RunPython(add_cheque), migrations.RunPython(add_cheque),

View file

@ -716,6 +716,12 @@ class Paiement(RevMixin, AclMixin, models.Model):
return cls.objects.all() return cls.objects.all()
return cls.objects.filter(available_for_everyone=True) 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): class Cotisation(RevMixin, AclMixin, models.Model):
""" """

View file

@ -24,7 +24,6 @@ from django.urls import reverse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _l from django.utils.translation import ugettext_lazy as _l
from django.contrib import messages from django.contrib import messages
from django.forms import ValidationError
from cotisations.models import Paiement from cotisations.models import Paiement
@ -35,6 +34,10 @@ class BalancePayment(PaymentMethodMixin, models.Model):
""" """
The model allowing you to pay with a cheque. The model allowing you to pay with a cheque.
""" """
class Meta:
verbose_name = _l("User Balance")
payment = models.OneToOneField( payment = models.OneToOneField(
Paiement, Paiement,
on_delete=models.CASCADE, on_delete=models.CASCADE,

View file

@ -21,6 +21,7 @@
from django.db import models from django.db import models
from django.shortcuts import redirect from django.shortcuts import redirect
from django.urls import reverse from django.urls import reverse
from django.utils.translation import ugettext_lazy as _l
from cotisations.models import Paiement from cotisations.models import Paiement
from cotisations.payment_methods.mixins import PaymentMethodMixin 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. The model allowing you to pay with a cheque.
""" """
class Meta:
verbose_name = _l("Cheque")
payment = models.OneToOneField( payment = models.OneToOneField(
Paiement, Paiement,
on_delete=models.CASCADE, on_delete=models.CASCADE,

View file

@ -35,6 +35,10 @@ class ComnpayPayment(PaymentMethodMixin, models.Model):
""" """
The model allowing you to pay with COMNPAY. The model allowing you to pay with COMNPAY.
""" """
class Meta:
verbose_name = "ComNpay"
payment = models.OneToOneField( payment = models.OneToOneField(
Paiement, Paiement,
on_delete=models.CASCADE, on_delete=models.CASCADE,

View file

@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr> <tr>
<th>{% trans "Payment type" %}</th> <th>{% trans "Payment type" %}</th>
<th>{% trans "Is available for everyone" %}</th> <th>{% trans "Is available for everyone" %}</th>
<th>{% trans "Custom payment method" %}</th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@ -37,6 +38,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr> <tr>
<td>{{ paiement.moyen }}</td> <td>{{ paiement.moyen }}</td>
<td>{{ paiement.available_for_everyone }}</td> <td>{{ paiement.available_for_everyone }}</td>
<td>
{{paiement.get_payment_method_name}}
</td>
<td class="text-right"> <td class="text-right">
{% can_edit paiement %} {% can_edit paiement %}
<a class="btn btn-primary btn-sm" role="button" title="{% trans "Edit" %}" href="{% url 'cotisations:edit-paiement' paiement.id %}"> <a class="btn btn-primary btn-sm" role="button" title="{% trans "Edit" %}" href="{% url 'cotisations:edit-paiement' paiement.id %}">