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

fix: Minor fixes to deposit app

This commit is contained in:
Jean-Romain Garnier 2021-08-06 14:18:38 +02:00
parent 824d882b81
commit 32b126d839
6 changed files with 8 additions and 6 deletions

View file

@ -26,14 +26,13 @@ from django import forms
from django.forms import Form, ModelForm from django.forms import Form, ModelForm
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from re2o.field_permissions import FieldPermissionFormMixin
from re2o.mixins import FormRevMixin from re2o.mixins import FormRevMixin
from re2o.widgets import AutocompleteModelWidget from re2o.widgets import AutocompleteModelWidget
from .models import Deposit, DepositItem 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. 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"].label = _("Member")
self.fields["user"].empty_label = _("Select the proprietary member") self.fields["user"].empty_label = _("Select the proprietary member")
self.fields["returned"].label = _("Deposit returned") self.fields["returned"].label = _("Deposit returned")
else:
self.fields = {"item": self.fields["item"]}
class Meta: class Meta:
model = Deposit model = Deposit

View file

@ -50,7 +50,7 @@ class Deposit(RevMixin, AclMixin, models.Model):
item = models.ForeignKey("DepositItem", on_delete=models.PROTECT) item = models.ForeignKey("DepositItem", 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"))
return_date = models.DateTimeField(default=None, verbose_name=_("return date")) return_date = models.DateTimeField(default=None, null=True, verbose_name=_("return date"))
class Meta: class Meta:
abstract = False abstract = False

View file

@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% for item in item_list %} {% for item in item_list %}
<tr> <tr>
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td>{{ item.deposit_amount }}</td> <td>{{ item.deposit_amount }}</td>
<td class="text-right"> <td class="text-right">
{% can_edit item %} {% can_edit item %}
{% include 'buttons/edit.html' with href='deposits:edit-deposit-item' id=item.id %} {% include 'buttons/edit.html' with href='deposits:edit-deposit-item' id=item.id %}

View file

@ -32,7 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<div id="deposits" class="panel-collapse collapse"> <div id="deposits" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body">
{% can_create Deposit %} {% can_create Deposit %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'deposits:new-deposit' %}"> <a class="btn btn-primary btn-sm" role="button" href="{% url 'deposits:new-deposit' users.id %}">
<i class="fa fa-balance-scale"></i> {% trans "Add a deposit" %} <i class="fa fa-balance-scale"></i> {% trans "Add a deposit" %}
</a> </a>
{% acl_end %} {% acl_end %}

View file

@ -39,5 +39,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i class="fa fa-trash"></i> {% trans "Delete one or several deposit items" %} <i class="fa fa-trash"></i> {% trans "Delete one or several deposit items" %}
</a> </a>
{% acl_end %} {% 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 %} {% endblock %}

View file

@ -228,6 +228,7 @@ def aff_profil(request, user):
deposits = re2o_paginator(request, deposits_list, pagination_number) deposits = re2o_paginator(request, deposits_list, pagination_number)
context = { context = {
"user": user,
"deposits_list": deposits, "deposits_list": deposits,
} }
return render_to_string( return render_to_string(