diff --git a/deposits/forms.py b/deposits/forms.py index d21c697e..9d919c44 100644 --- a/deposits/forms.py +++ b/deposits/forms.py @@ -40,14 +40,19 @@ class DepositForm(FormRevMixin, ModelForm): user = kwargs.pop("user") super(DepositForm, self).__init__(*args, **kwargs) - if not creation: - self.fields["returned"].label = _("Deposit returned") + if creation: + # 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: - self.fields = {"item": self.fields["item"]} + self.fields["returned"].label = _("Deposit returned") class Meta: model = Deposit - fields = ("item", "returned") + fields = ("item", "payment_method", "returned") class DepositItemForm(FormRevMixin, ModelForm): diff --git a/deposits/locale/fr/LC_MESSAGES/django.po b/deposits/locale/fr/LC_MESSAGES/django.po index 5e1d4bd1..a2026fb6 100644 --- a/deposits/locale/fr/LC_MESSAGES/django.po +++ b/deposits/locale/fr/LC_MESSAGES/django.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\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" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -31,67 +31,67 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: deposits/forms.py:44 +#: deposits/forms.py:51 msgid "Deposit returned" msgstr "Caution rendue" -#: deposits/forms.py:71 +#: deposits/forms.py:76 msgid "Current deposit items" msgstr "Articles sous cautions actuels" -#: deposits/models.py:51 +#: deposits/models.py:52 msgid "date" msgstr "date" -#: deposits/models.py:52 +#: deposits/models.py:53 msgid "returned" msgstr "rendu" -#: deposits/models.py:54 deposits/models.py:139 +#: deposits/models.py:55 deposits/models.py:140 msgid "deposit amount" msgstr "montant de la caution" -#: deposits/models.py:59 deposits/views.py:113 +#: deposits/models.py:60 deposits/views.py:113 msgid "deposit" msgstr "caution" -#: deposits/models.py:60 +#: deposits/models.py:61 msgid "deposits" msgstr "cautions" -#: deposits/models.py:69 +#: deposits/models.py:70 #, python-brace-format msgid "Deposit from {name} for {item} at {date}, returned" msgstr "Caution de {name} pour {item} à {date}, rendu" -#: deposits/models.py:76 +#: deposits/models.py:77 #, python-brace-format msgid "Deposit from {name} for {item} at {date}, not yet returned" 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." 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." msgstr "Vous n'avez pas le droit de voir la liste des cautions." -#: deposits/models.py:136 +#: deposits/models.py:137 msgid "designation" msgstr "désignation" -#: deposits/models.py:144 +#: deposits/models.py:145 msgid "deposit item" msgstr "article" -#: deposits/models.py:145 +#: deposits/models.py:146 msgid "deposit items" msgstr "articles" #: deposits/templates/deposits/aff_deposit_item.html:31 -msgid "Deposit" -msgstr "Caution" +msgid "Deposit item" +msgstr "Article" #: deposits/templates/deposits/aff_deposit_item.html:32 #: deposits/templates/deposits/aff_deposits.html:37 @@ -107,10 +107,14 @@ msgid "Item" msgstr "Article" #: deposits/templates/deposits/aff_deposits.html:38 +msgid "Payment method" +msgstr "Moyen de paiement" + +#: deposits/templates/deposits/aff_deposits.html:39 msgid "Date" msgstr "Date" -#: deposits/templates/deposits/aff_deposits.html:39 +#: deposits/templates/deposits/aff_deposits.html:40 msgid "Returned" msgstr "Rendu" diff --git a/deposits/migrations/0001_initial.py b/deposits/migrations/0001_initial.py index 02b03fbd..dadcb74f 100644 --- a/deposits/migrations/0001_initial.py +++ b/deposits/migrations/0001_initial.py @@ -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.db import migrations, models @@ -12,6 +12,7 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('cotisations', '0004_auto_20210208_1827'), ] operations = [ @@ -37,6 +38,7 @@ class Migration(migrations.Migration): ('returned', models.BooleanField(default=False, verbose_name='returned')), ('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')), + ('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)), ], options={ diff --git a/deposits/models.py b/deposits/models.py index 6469f6e4..efea975a 100644 --- a/deposits/models.py +++ b/deposits/models.py @@ -48,6 +48,7 @@ class Deposit(RevMixin, AclMixin, models.Model): user = models.ForeignKey("users.User", 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")) returned = models.BooleanField(default=False, verbose_name=_("returned")) deposit_amount = models.DecimalField( diff --git a/deposits/templates/deposits/aff_deposit_item.html b/deposits/templates/deposits/aff_deposit_item.html index 0c0b1c06..60bff968 100644 --- a/deposits/templates/deposits/aff_deposit_item.html +++ b/deposits/templates/deposits/aff_deposit_item.html @@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc., - + diff --git a/deposits/templates/deposits/aff_deposits.html b/deposits/templates/deposits/aff_deposits.html index 09263b46..8b70ecee 100644 --- a/deposits/templates/deposits/aff_deposits.html +++ b/deposits/templates/deposits/aff_deposits.html @@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc., + @@ -44,6 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc., + {% if deposit.returned %}
{% trans "Deposit" %}{% trans "Deposit item" %} {% trans "Amount" %}
{% trans "User" %} {% trans "Item" %} {% trans "Amount" %}{% trans "Payment method" %} {% trans "Date" %} {% trans "Returned" %} {{ deposit.user.get_short_name }} {{ deposit.item.name }} {{ deposit.deposit_amount }} €{{ deposit.payment_method.moyen }} {{ deposit.date }}