From 32b126d839e83bdafa97d107ffbd403ebf1fe7d8 Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Fri, 6 Aug 2021 14:18:38 +0200 Subject: [PATCH] fix: Minor fixes to deposit app --- deposits/forms.py | 5 +++-- deposits/models.py | 2 +- deposits/templates/deposits/aff_deposit_item.html | 2 +- deposits/templates/deposits/aff_profil.html | 2 +- deposits/templates/deposits/index_deposit_item.html | 2 +- deposits/views.py | 1 + 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/deposits/forms.py b/deposits/forms.py index 460fbfe7..12627278 100644 --- a/deposits/forms.py +++ b/deposits/forms.py @@ -26,14 +26,13 @@ from django import forms from django.forms import Form, ModelForm from django.utils.translation import ugettext_lazy as _ -from re2o.field_permissions import FieldPermissionFormMixin from re2o.mixins import FormRevMixin from re2o.widgets import AutocompleteModelWidget from .models import Deposit, DepositItem -class DepositForm(FieldPermissionFormMixin, FormRevMixin, ModelForm): +class DepositForm(FormRevMixin, ModelForm): """ Form used to manage and create an invoice and its fields. """ @@ -45,6 +44,8 @@ class DepositForm(FieldPermissionFormMixin, FormRevMixin, ModelForm): self.fields["user"].label = _("Member") self.fields["user"].empty_label = _("Select the proprietary member") self.fields["returned"].label = _("Deposit returned") + else: + self.fields = {"item": self.fields["item"]} class Meta: model = Deposit diff --git a/deposits/models.py b/deposits/models.py index 81b3ee2d..7de37e67 100644 --- a/deposits/models.py +++ b/deposits/models.py @@ -50,7 +50,7 @@ class Deposit(RevMixin, AclMixin, models.Model): item = models.ForeignKey("DepositItem", on_delete=models.PROTECT) date = models.DateTimeField(auto_now_add=True, verbose_name=_("date")) returned = models.BooleanField(default=False, verbose_name=_("returned")) - return_date = models.DateTimeField(default=None, verbose_name=_("return date")) + return_date = models.DateTimeField(default=None, null=True, verbose_name=_("return date")) class Meta: abstract = False diff --git a/deposits/templates/deposits/aff_deposit_item.html b/deposits/templates/deposits/aff_deposit_item.html index 702b340a..0c0b1c06 100644 --- a/deposits/templates/deposits/aff_deposit_item.html +++ b/deposits/templates/deposits/aff_deposit_item.html @@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% for item in item_list %} {{ item.name }} - {{ item.deposit_amount }} + {{ item.deposit_amount }} € {% can_edit item %} {% include 'buttons/edit.html' with href='deposits:edit-deposit-item' id=item.id %} diff --git a/deposits/templates/deposits/aff_profil.html b/deposits/templates/deposits/aff_profil.html index 14ee6e2b..862f4a4d 100644 --- a/deposits/templates/deposits/aff_profil.html +++ b/deposits/templates/deposits/aff_profil.html @@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% can_create Deposit %} - + {% trans "Add a deposit" %} {% acl_end %} diff --git a/deposits/templates/deposits/index_deposit_item.html b/deposits/templates/deposits/index_deposit_item.html index 13cfe6b5..0bfe5bc0 100644 --- a/deposits/templates/deposits/index_deposit_item.html +++ b/deposits/templates/deposits/index_deposit_item.html @@ -39,5 +39,5 @@ with this program; if not, write to the Free Software Foundation, Inc., {% trans "Delete one or several deposit items" %} {% acl_end %} - {% include 'deposits/aff_deposit_item.html' with item_list=item_list %} + {% include 'deposits/aff_deposit_item.html' with item_list=item_list %} {% endblock %} diff --git a/deposits/views.py b/deposits/views.py index 2a466c07..9cca8a75 100644 --- a/deposits/views.py +++ b/deposits/views.py @@ -228,6 +228,7 @@ def aff_profil(request, user): deposits = re2o_paginator(request, deposits_list, pagination_number) context = { + "user": user, "deposits_list": deposits, } return render_to_string(