8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 15:33:45 +00:00

feat: Add payment method to deposits

This commit is contained in:
Jean-Romain Garnier 2021-08-07 13:23:06 +02:00
parent dfc58a281e
commit 7b5d21c6b1
6 changed files with 38 additions and 24 deletions

View file

@ -40,14 +40,19 @@ class DepositForm(FormRevMixin, ModelForm):
user = kwargs.pop("user") user = kwargs.pop("user")
super(DepositForm, self).__init__(*args, **kwargs) super(DepositForm, self).__init__(*args, **kwargs)
if not creation: if creation:
self.fields["returned"].label = _("Deposit returned") # During creation, we only need to select the item and payment
# method, no need to add the "returned" checkbox
self.fields = {
"item": self.fields["item"],
"payment_method": self.fields["payment_method"],
}
else: else:
self.fields = {"item": self.fields["item"]} self.fields["returned"].label = _("Deposit returned")
class Meta: class Meta:
model = Deposit model = Deposit
fields = ("item", "returned") fields = ("item", "payment_method", "returned")
class DepositItemForm(FormRevMixin, ModelForm): class DepositItemForm(FormRevMixin, ModelForm):

View file

@ -21,7 +21,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-06 16:33+0200\n" "POT-Creation-Date: 2021-08-07 13:20+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -31,67 +31,67 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: deposits/forms.py:44 #: deposits/forms.py:51
msgid "Deposit returned" msgid "Deposit returned"
msgstr "Caution rendue" msgstr "Caution rendue"
#: deposits/forms.py:71 #: deposits/forms.py:76
msgid "Current deposit items" msgid "Current deposit items"
msgstr "Articles sous cautions actuels" msgstr "Articles sous cautions actuels"
#: deposits/models.py:51 #: deposits/models.py:52
msgid "date" msgid "date"
msgstr "date" msgstr "date"
#: deposits/models.py:52 #: deposits/models.py:53
msgid "returned" msgid "returned"
msgstr "rendu" msgstr "rendu"
#: deposits/models.py:54 deposits/models.py:139 #: deposits/models.py:55 deposits/models.py:140
msgid "deposit amount" msgid "deposit amount"
msgstr "montant de la caution" msgstr "montant de la caution"
#: deposits/models.py:59 deposits/views.py:113 #: deposits/models.py:60 deposits/views.py:113
msgid "deposit" msgid "deposit"
msgstr "caution" msgstr "caution"
#: deposits/models.py:60 #: deposits/models.py:61
msgid "deposits" msgid "deposits"
msgstr "cautions" msgstr "cautions"
#: deposits/models.py:69 #: deposits/models.py:70
#, python-brace-format #, python-brace-format
msgid "Deposit from {name} for {item} at {date}, returned" msgid "Deposit from {name} for {item} at {date}, returned"
msgstr "Caution de {name} pour {item} à {date}, rendu" msgstr "Caution de {name} pour {item} à {date}, rendu"
#: deposits/models.py:76 #: deposits/models.py:77
#, python-brace-format #, python-brace-format
msgid "Deposit from {name} for {item} at {date}, not yet returned" msgid "Deposit from {name} for {item} at {date}, not yet returned"
msgstr "Caution de {name} pour {item} à {date}, pas encore rendu" msgstr "Caution de {name} pour {item} à {date}, pas encore rendu"
#: deposits/models.py:104 #: deposits/models.py:105
msgid "You don't have the right to view other deposits than yours." msgid "You don't have the right to view other deposits than yours."
msgstr "Vous n'avez pas le droit de voir les cautions d'autres utilisateurs." msgstr "Vous n'avez pas le droit de voir les cautions d'autres utilisateurs."
#: deposits/models.py:116 #: deposits/models.py:117
msgid "You don't have the right to view the list of deposits." msgid "You don't have the right to view the list of deposits."
msgstr "Vous n'avez pas le droit de voir la liste des cautions." msgstr "Vous n'avez pas le droit de voir la liste des cautions."
#: deposits/models.py:136 #: deposits/models.py:137
msgid "designation" msgid "designation"
msgstr "désignation" msgstr "désignation"
#: deposits/models.py:144 #: deposits/models.py:145
msgid "deposit item" msgid "deposit item"
msgstr "article" msgstr "article"
#: deposits/models.py:145 #: deposits/models.py:146
msgid "deposit items" msgid "deposit items"
msgstr "articles" msgstr "articles"
#: deposits/templates/deposits/aff_deposit_item.html:31 #: deposits/templates/deposits/aff_deposit_item.html:31
msgid "Deposit" msgid "Deposit item"
msgstr "Caution" msgstr "Article"
#: deposits/templates/deposits/aff_deposit_item.html:32 #: deposits/templates/deposits/aff_deposit_item.html:32
#: deposits/templates/deposits/aff_deposits.html:37 #: deposits/templates/deposits/aff_deposits.html:37
@ -107,10 +107,14 @@ msgid "Item"
msgstr "Article" msgstr "Article"
#: deposits/templates/deposits/aff_deposits.html:38 #: deposits/templates/deposits/aff_deposits.html:38
msgid "Payment method"
msgstr "Moyen de paiement"
#: deposits/templates/deposits/aff_deposits.html:39
msgid "Date" msgid "Date"
msgstr "Date" msgstr "Date"
#: deposits/templates/deposits/aff_deposits.html:39 #: deposits/templates/deposits/aff_deposits.html:40
msgid "Returned" msgid "Returned"
msgstr "Rendu" msgstr "Rendu"

View file

@ -1,4 +1,4 @@
# Generated by Django 2.2.18 on 2021-08-06 13:54 # Generated by Django 2.2.18 on 2021-08-07 11:08
from django.conf import settings from django.conf import settings
from django.db import migrations, models from django.db import migrations, models
@ -12,6 +12,7 @@ class Migration(migrations.Migration):
dependencies = [ dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('cotisations', '0004_auto_20210208_1827'),
] ]
operations = [ operations = [
@ -37,6 +38,7 @@ class Migration(migrations.Migration):
('returned', models.BooleanField(default=False, verbose_name='returned')), ('returned', models.BooleanField(default=False, verbose_name='returned')),
('deposit_amount', models.DecimalField(decimal_places=2, max_digits=5, verbose_name='deposit amount')), ('deposit_amount', models.DecimalField(decimal_places=2, max_digits=5, verbose_name='deposit amount')),
('item', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='deposits.DepositItem')), ('item', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='deposits.DepositItem')),
('payment_method', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cotisations.Paiement')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)), ('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
], ],
options={ options={

View file

@ -48,6 +48,7 @@ class Deposit(RevMixin, AclMixin, models.Model):
user = models.ForeignKey("users.User", on_delete=models.PROTECT) user = models.ForeignKey("users.User", on_delete=models.PROTECT)
item = models.ForeignKey("DepositItem", on_delete=models.PROTECT) item = models.ForeignKey("DepositItem", on_delete=models.PROTECT)
payment_method = models.ForeignKey("cotisations.Paiement", on_delete=models.PROTECT)
date = models.DateTimeField(auto_now_add=True, verbose_name=_("date")) date = models.DateTimeField(auto_now_add=True, verbose_name=_("date"))
returned = models.BooleanField(default=False, verbose_name=_("returned")) returned = models.BooleanField(default=False, verbose_name=_("returned"))
deposit_amount = models.DecimalField( deposit_amount = models.DecimalField(

View file

@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>{% trans "Deposit" %}</th> <th>{% trans "Deposit item" %}</th>
<th>{% trans "Amount" %}</th> <th>{% trans "Amount" %}</th>
<th></th> <th></th>
</tr> </tr>

View file

@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th scope="col">{% trans "User" %}</th> <th scope="col">{% trans "User" %}</th>
<th scope="col">{% trans "Item" %}</th> <th scope="col">{% trans "Item" %}</th>
<th scope="col">{% trans "Amount" %}</th> <th scope="col">{% trans "Amount" %}</th>
<th scope="col">{% trans "Payment method" %}</th>
<th scope="col">{% trans "Date" %}</th> <th scope="col">{% trans "Date" %}</th>
<th scope="col">{% trans "Returned" %}</th> <th scope="col">{% trans "Returned" %}</th>
<th scope="col"></th> <th scope="col"></th>
@ -44,6 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td><a href="{% url 'users:profil' deposit.user.id %}" role="button">{{ deposit.user.get_short_name }}</a></td> <td><a href="{% url 'users:profil' deposit.user.id %}" role="button">{{ deposit.user.get_short_name }}</a></td>
<td>{{ deposit.item.name }}</td> <td>{{ deposit.item.name }}</td>
<td>{{ deposit.deposit_amount }} €</td> <td>{{ deposit.deposit_amount }} €</td>
<td>{{ deposit.payment_method.moyen }}</td>
<td>{{ deposit.date }}</td> <td>{{ deposit.date }}</td>
{% if deposit.returned %} {% if deposit.returned %}
<td><i class="fa fa-check" style="color:green"></i></td> <td><i class="fa fa-check" style="color:green"></i></td>