diff --git a/deposits/forms.py b/deposits/forms.py index 12627278..d21c697e 100644 --- a/deposits/forms.py +++ b/deposits/forms.py @@ -27,7 +27,6 @@ from django.forms import Form, ModelForm from django.utils.translation import ugettext_lazy as _ from re2o.mixins import FormRevMixin -from re2o.widgets import AutocompleteModelWidget from .models import Deposit, DepositItem @@ -38,21 +37,17 @@ class DepositForm(FormRevMixin, ModelForm): """ def __init__(self, *args, creation=False, **kwargs): + user = kwargs.pop("user") super(DepositForm, self).__init__(*args, **kwargs) if not creation: - 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 - fields = ("user", "item", "returned") - widgets = { - "user": AutocompleteModelWidget(url="/users/user-autocomplete"), - } + fields = ("item", "returned") class DepositItemForm(FormRevMixin, ModelForm): diff --git a/deposits/models.py b/deposits/models.py index 7de37e67..d41fcfc3 100644 --- a/deposits/models.py +++ b/deposits/models.py @@ -42,15 +42,13 @@ class Deposit(RevMixin, AclMixin, models.Model): * an item (borrowed in exchange for the deposit) Every deposit is dated throught the 'date' value. A deposit has a 'returned' value (default: False) which means that the item - was returned by the user and the deposit was payed back. The - 'returned_date' attribute stores when the item was returned. + was returned by the user and the deposit was payed back. """ user = models.ForeignKey("users.User", on_delete=models.PROTECT) 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, null=True, verbose_name=_("return date")) class Meta: abstract = False @@ -60,12 +58,11 @@ class Deposit(RevMixin, AclMixin, models.Model): def __str__(self): if self.returned: return _( - "Deposit from {name} for {item} at {date}, returned at {return_date}" + "Deposit from {name} for {item} at {date}, returned" ).format( name=self.user.get_full_name(), item=self.item, date=self.date, - return_date=self.return_date, ) else: return _( diff --git a/deposits/templates/deposits/aff_deposit.html b/deposits/templates/deposits/aff_deposit.html deleted file mode 100644 index f9284d7b..00000000 --- a/deposits/templates/deposits/aff_deposit.html +++ /dev/null @@ -1,74 +0,0 @@ -{% extends 'users/sidebar.html' %} -{% comment %} -Re2o est un logiciel d'administration développé initiallement au Rézo Metz. Il -se veut agnostique au réseau considéré, de manière à être installable en -quelques clics. - -Copyright © 2021 Jean-Romain Garnier - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -{% endcomment %} - -{% load bootstrap3 %} -{% load i18n %} -{% load humanize %} -{% load logs_extra %} -{% load acl %} - -{% block title %}{% trans "Deposits" %}{% endblock %} - -{% block content %} - -
{% trans "Item:" %} {{deposit.item}}
- -{% trans "User" %} | {% trans "Item" %} | {% trans "Amount" %} | {% trans "Date" %} | -{% trans "Returned" %} | +{% trans "Returned" %} | +|||
---|---|---|---|---|---|---|---|---|
- - - - | -{{ deposit.user.get_short_name }} | +{{ deposit.user.get_short_name }} | {{ deposit.item.name }} | {{ deposit.item.deposit_amount }} € | {{ deposit.date }} | @@ -52,7 +49,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,{% else %} | - {% endif %} + {% endif %} + | + {% can_edit deposit %} + {% include 'buttons/edit.html' with href='deposits:edit-deposit' id=deposit.id %} + {% acl_end %} + {% history_button deposit %} + |