mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-24 04:13:12 +00:00
feat: Add page listing all deposits
This commit is contained in:
parent
7ecfb35925
commit
e954908323
7 changed files with 252 additions and 55 deletions
|
@ -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-07 13:20+0200\n"
|
"POT-Creation-Date: 2021-08-07 18:27+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,11 +31,19 @@ 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:51
|
#: deposits/forms.py:44 deposits/templates/deposits/aff_deposit_item.html:31
|
||||||
|
msgid "Deposit item"
|
||||||
|
msgstr "Article"
|
||||||
|
|
||||||
|
#: deposits/forms.py:45 deposits/templates/deposits/aff_deposits.html:48
|
||||||
|
msgid "Payment method"
|
||||||
|
msgstr "Moyen de paiement"
|
||||||
|
|
||||||
|
#: deposits/forms.py:46
|
||||||
msgid "Deposit returned"
|
msgid "Deposit returned"
|
||||||
msgstr "Caution rendue"
|
msgstr "Caution rendue"
|
||||||
|
|
||||||
#: deposits/forms.py:76
|
#: deposits/forms.py:79
|
||||||
msgid "Current deposit items"
|
msgid "Current deposit items"
|
||||||
msgstr "Articles sous cautions actuels"
|
msgstr "Articles sous cautions actuels"
|
||||||
|
|
||||||
|
@ -51,7 +59,7 @@ msgstr "rendu"
|
||||||
msgid "deposit amount"
|
msgid "deposit amount"
|
||||||
msgstr "montant de la caution"
|
msgstr "montant de la caution"
|
||||||
|
|
||||||
#: deposits/models.py:60 deposits/views.py:113
|
#: deposits/models.py:60 deposits/views.py:114
|
||||||
msgid "deposit"
|
msgid "deposit"
|
||||||
msgstr "caution"
|
msgstr "caution"
|
||||||
|
|
||||||
|
@ -89,36 +97,29 @@ msgstr "article"
|
||||||
msgid "deposit items"
|
msgid "deposit items"
|
||||||
msgstr "articles"
|
msgstr "articles"
|
||||||
|
|
||||||
#: deposits/templates/deposits/aff_deposit_item.html:31
|
|
||||||
msgid "Deposit item"
|
|
||||||
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:44
|
||||||
msgid "Amount"
|
msgid "Amount"
|
||||||
msgstr "Montant"
|
msgstr "Montant"
|
||||||
|
|
||||||
#: deposits/templates/deposits/aff_deposits.html:35
|
#: deposits/templates/deposits/aff_deposits.html:36
|
||||||
msgid "User"
|
msgid "User"
|
||||||
msgstr "Utilisateur"
|
msgstr "Utilisateur"
|
||||||
|
|
||||||
#: deposits/templates/deposits/aff_deposits.html:36
|
#: deposits/templates/deposits/aff_deposits.html:40
|
||||||
msgid "Item"
|
msgid "Item"
|
||||||
msgstr "Article"
|
msgstr "Article"
|
||||||
|
|
||||||
#: deposits/templates/deposits/aff_deposits.html:38
|
#: deposits/templates/deposits/aff_deposits.html:52
|
||||||
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:40
|
#: deposits/templates/deposits/aff_deposits.html:56
|
||||||
msgid "Returned"
|
msgid "Returned"
|
||||||
msgstr "Rendu"
|
msgstr "Rendu"
|
||||||
|
|
||||||
#: deposits/templates/deposits/aff_profil.html:29
|
#: deposits/templates/deposits/aff_profil.html:29
|
||||||
|
#: deposits/templates/deposits/navbar.html:25
|
||||||
msgid "Deposits"
|
msgid "Deposits"
|
||||||
msgstr "Cautions"
|
msgstr "Cautions"
|
||||||
|
|
||||||
|
@ -143,7 +144,7 @@ msgstr ""
|
||||||
"Attention: voulez-vous vraiment supprimer cet objet %(objet_name)s "
|
"Attention: voulez-vous vraiment supprimer cet objet %(objet_name)s "
|
||||||
"( %(objet)s ) ?"
|
"( %(objet)s ) ?"
|
||||||
|
|
||||||
#: deposits/templates/deposits/delete.html:36 deposits/views.py:69
|
#: deposits/templates/deposits/delete.html:36 deposits/views.py:70
|
||||||
msgid "Confirm"
|
msgid "Confirm"
|
||||||
msgstr "Confirmer"
|
msgstr "Confirmer"
|
||||||
|
|
||||||
|
@ -151,12 +152,12 @@ msgstr "Confirmer"
|
||||||
msgid "Create or edit deposit"
|
msgid "Create or edit deposit"
|
||||||
msgstr "Créer ou modifier les cautions"
|
msgstr "Créer ou modifier les cautions"
|
||||||
|
|
||||||
#: deposits/templates/deposits/deposit.html:35 deposits/views.py:144
|
#: deposits/templates/deposits/deposit.html:35 deposits/views.py:173
|
||||||
msgid "Add"
|
msgid "Add"
|
||||||
msgstr "Ajouter"
|
msgstr "Ajouter"
|
||||||
|
|
||||||
#: deposits/templates/deposits/index_deposit_item.html:27
|
#: deposits/templates/deposits/index_deposit_item.html:27
|
||||||
#: deposits/templates/deposits/navbar.html:24
|
#: deposits/templates/deposits/navbar.html:33
|
||||||
msgid "Deposit items"
|
msgid "Deposit items"
|
||||||
msgstr "Articles sous caution"
|
msgstr "Articles sous caution"
|
||||||
|
|
||||||
|
@ -172,54 +173,82 @@ msgstr "Ajouter un article"
|
||||||
msgid "Delete one or several deposit items"
|
msgid "Delete one or several deposit items"
|
||||||
msgstr "Supprimer ou un plusieurs articles"
|
msgstr "Supprimer ou un plusieurs articles"
|
||||||
|
|
||||||
#: deposits/views.py:63
|
#: deposits/templates/deposits/index_deposits.html:29
|
||||||
|
msgid "List of deposits"
|
||||||
|
msgstr "Liste de cautions"
|
||||||
|
|
||||||
|
#: deposits/templates/deposits/index_deposits.html:35
|
||||||
|
msgid "Deposit"
|
||||||
|
msgid_plural "Deposits"
|
||||||
|
msgstr[0] "Caution"
|
||||||
|
msgstr[1] "Cautions"
|
||||||
|
|
||||||
|
#: deposits/templates/deposits/index_deposits.html:38
|
||||||
|
msgid "Unreturned deposit"
|
||||||
|
msgid_plural "Unreturned deposits"
|
||||||
|
msgstr[0] "Caution non rendue"
|
||||||
|
msgstr[1] "Cautions non rendues"
|
||||||
|
|
||||||
|
#: deposits/templates/deposits/index_deposits.html:46
|
||||||
|
msgid "Unreturned deposits"
|
||||||
|
msgstr "Cautions non rendues"
|
||||||
|
|
||||||
|
#: deposits/templates/deposits/index_deposits.html:57
|
||||||
|
msgid "Returned deposits"
|
||||||
|
msgstr "Cautions rendues"
|
||||||
|
|
||||||
|
#: deposits/templates/deposits/navbar.html:30
|
||||||
|
msgid "View deposits"
|
||||||
|
msgstr "Gérer les cautions"
|
||||||
|
|
||||||
|
#: deposits/views.py:64
|
||||||
msgid "The deposit was created."
|
msgid "The deposit was created."
|
||||||
msgstr "La caution a été crée."
|
msgstr "La caution a été crée."
|
||||||
|
|
||||||
#: deposits/views.py:70
|
#: deposits/views.py:71
|
||||||
msgid "New deposit"
|
msgid "New deposit"
|
||||||
msgstr "Nouvelle caution"
|
msgstr "Nouvelle caution"
|
||||||
|
|
||||||
#: deposits/views.py:88
|
#: deposits/views.py:89
|
||||||
msgid "The deposit was edited."
|
msgid "The deposit was edited."
|
||||||
msgstr "La caution a été modifiée."
|
msgstr "La caution a été modifiée."
|
||||||
|
|
||||||
#: deposits/views.py:94 deposits/views.py:167
|
#: deposits/views.py:95 deposits/views.py:196
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr "Modifier"
|
msgstr "Modifier"
|
||||||
|
|
||||||
#: deposits/views.py:95
|
#: deposits/views.py:96
|
||||||
msgid "Edit deposit"
|
msgid "Edit deposit"
|
||||||
msgstr "Modifier la caution"
|
msgstr "Modifier la caution"
|
||||||
|
|
||||||
#: deposits/views.py:110
|
#: deposits/views.py:111
|
||||||
msgid "The deposit was deleted."
|
msgid "The deposit was deleted."
|
||||||
msgstr "La caution a été supprimée."
|
msgstr "La caution a été supprimée."
|
||||||
|
|
||||||
#: deposits/views.py:139
|
#: deposits/views.py:168
|
||||||
msgid "The item was created."
|
msgid "The item was created."
|
||||||
msgstr "L'article a été créé."
|
msgstr "L'article a été créé."
|
||||||
|
|
||||||
#: deposits/views.py:145
|
#: deposits/views.py:174
|
||||||
msgid "New deposit item"
|
msgid "New deposit item"
|
||||||
msgstr "Nouvel article"
|
msgstr "Nouvel article"
|
||||||
|
|
||||||
#: deposits/views.py:162
|
#: deposits/views.py:191
|
||||||
msgid "The item was edited."
|
msgid "The item was edited."
|
||||||
msgstr "L'article a été modifié."
|
msgstr "L'article a été modifié."
|
||||||
|
|
||||||
#: deposits/views.py:168
|
#: deposits/views.py:197
|
||||||
msgid "Edit deposit item"
|
msgid "Edit deposit item"
|
||||||
msgstr "Modifier l'article"
|
msgstr "Modifier l'article"
|
||||||
|
|
||||||
#: deposits/views.py:185
|
#: deposits/views.py:214
|
||||||
msgid "The items were deleted."
|
msgid "The items were deleted."
|
||||||
msgstr "Les articles ont été supprimés."
|
msgstr "Les articles ont été supprimés."
|
||||||
|
|
||||||
#: deposits/views.py:190
|
#: deposits/views.py:219
|
||||||
msgid "Delete"
|
msgid "Delete"
|
||||||
msgstr "Supprimer"
|
msgstr "Supprimer"
|
||||||
|
|
||||||
#: deposits/views.py:191
|
#: deposits/views.py:220
|
||||||
msgid "Delete deposit item"
|
msgid "Delete deposit item"
|
||||||
msgstr "Supprimer l'article"
|
msgstr "Supprimer l'article"
|
||||||
|
|
|
@ -32,13 +32,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">{% trans "User" %}</th>
|
<th>
|
||||||
<th scope="col">{% trans "Item" %}</th>
|
{% trans "User" as tr_user %}
|
||||||
<th scope="col">{% trans "Amount" %}</th>
|
{% include 'buttons/sort.html' with prefix='deposit' col="user" text=tr_user %}
|
||||||
<th scope="col">{% trans "Payment method" %}</th>
|
</th>
|
||||||
<th scope="col">{% trans "Date" %}</th>
|
<th>
|
||||||
<th scope="col">{% trans "Returned" %}</th>
|
{% trans "Item" as tr_item %}
|
||||||
<th scope="col"></th>
|
{% include 'buttons/sort.html' with prefix='deposit' col="item" text=tr_item %}
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
{% trans "Amount" as tr_amount %}
|
||||||
|
{% include 'buttons/sort.html' with prefix='deposit' col="amount" text=tr_amount %}
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
{% trans "Payment method" as tr_payment %}
|
||||||
|
{% include 'buttons/sort.html' with prefix='deposit' col="payment" text=tr_payment %}
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
{% trans "Date" as tr_date %}
|
||||||
|
{% include 'buttons/sort.html' with prefix='deposit' col="date" text=tr_date %}
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
{% trans "Returned" as tr_returned %}
|
||||||
|
{% include 'buttons/sort.html' with prefix='deposit' col="returned" text=tr_returned %}
|
||||||
|
</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for deposit in deposits_list %}
|
{% for deposit in deposits_list %}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -64,7 +82,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% if deposits_list.paginator %}
|
{% if deposits_list.paginator and show_pagination is not False %}
|
||||||
{% include 'pagination.html' with list=deposits_list go_to_id="deposits" %}
|
{% include 'pagination.html' with list=deposits_list go_to_id="deposits" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
64
deposits/templates/deposits/index_deposits.html
Normal file
64
deposits/templates/deposits/index_deposits.html
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
{% extends 'deposits/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 acl %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% load logs_extra %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>{% trans "List of deposits" %}</h2>
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<hr class="col-sm-12">
|
||||||
|
<div class="row justify-content-start">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<span class="badge badge-light"> {{ nbr_deposits }}</span> {% blocktrans count nb=nbr_deposits %}Deposit{% plural %}Deposits{% endblocktrans %}
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<span class="badge badge-light"> {{ nbr_deposits_lent }}</span> {% blocktrans count nb=nbr_deposits_lent %}Unreturned deposit{% plural %}Unreturned deposits{% endblocktrans %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr class="col-sm-12">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="unreturned_deposits">
|
||||||
|
<h3>{% trans "Unreturned deposits" %}</h2>
|
||||||
|
{% include 'deposits/aff_deposits.html' with deposits_list=lent_deposits_list show_pagination=False %}
|
||||||
|
|
||||||
|
{% if lent_deposits_list.paginator %}
|
||||||
|
{% include 'pagination.html' with list=lent_deposits_list page_arg='lpage' go_to_id='unreturned_deposits' %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<div id="returned_deposits">
|
||||||
|
<h3>{% trans "Returned deposits" %}</h2>
|
||||||
|
{% include 'deposits/aff_deposits.html' with deposits_list=returned_deposits_list show_pagination=False %}
|
||||||
|
|
||||||
|
{% if returned_deposits_list.paginator %}
|
||||||
|
{% include 'pagination.html' with list=returned_deposits_list page_arg='rpage' go_to_id='returned_deposits' %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -21,4 +21,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
<li><a href="{% url 'deposits:index-deposit-item' %}"><i class="fa fa-balance-scale"></i> {% trans "Deposit items" %}</a></li>
|
<li><a class="dropdown-item" href="#"><i class="fa fa-balance-scale"></i>
|
||||||
|
{% trans "Deposits" %}
|
||||||
|
» </a>
|
||||||
|
<ul class="submenu dropdown-menu">
|
||||||
|
<li><a class="dropdown-item" href="{% url 'deposits:index-deposits' %}"><i
|
||||||
|
class="fa fa-eye"></i>
|
||||||
|
{% trans "View deposits" %}</a></li>
|
||||||
|
<li><a class="dropdown-item" href="{% url 'deposits:index-deposit-item' %}"><i
|
||||||
|
class="fa fa-barcode"></i>
|
||||||
|
{% trans "Deposit items" %}</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
|
@ -32,11 +32,7 @@ urlpatterns = [
|
||||||
path("new_deposit/<int:userid>", views.new_deposit, name="new-deposit"),
|
path("new_deposit/<int:userid>", views.new_deposit, name="new-deposit"),
|
||||||
path("edit_deposit/<int:depositid>", views.edit_deposit, name="edit-deposit"),
|
path("edit_deposit/<int:depositid>", views.edit_deposit, name="edit-deposit"),
|
||||||
path("del_deposit/<int:depositid>", views.del_deposit, name="del-deposit"),
|
path("del_deposit/<int:depositid>", views.del_deposit, name="del-deposit"),
|
||||||
path(
|
path("index_deposits", views.index_deposits, name="index-deposits"),
|
||||||
"change_deposit_status/<int:depositid>",
|
|
||||||
views.change_deposit_status,
|
|
||||||
name="change-deposit-status",
|
|
||||||
),
|
|
||||||
path("add_deposit_item", views.add_deposit_item, name="add-deposit-item"),
|
path("add_deposit_item", views.add_deposit_item, name="add-deposit-item"),
|
||||||
path(
|
path(
|
||||||
"edit_deposit_item/<int:itemid>",
|
"edit_deposit_item/<int:itemid>",
|
||||||
|
|
38
deposits/utils.py
Normal file
38
deposits/utils.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# 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.
|
||||||
|
"""
|
||||||
|
Deposits utils
|
||||||
|
"""
|
||||||
|
from re2o.base import SortTable
|
||||||
|
|
||||||
|
|
||||||
|
class DepositSortTable(SortTable):
|
||||||
|
"""Extension of the SortTable class to handle the deposit optional app"""
|
||||||
|
|
||||||
|
DEPOSIT_INDEX = {
|
||||||
|
"deposit_user": ["user__pseudo"],
|
||||||
|
"deposit_item": ["item__name"],
|
||||||
|
"deposit_payment": ["payment_method__moyen"],
|
||||||
|
"deposit_date": ["date"],
|
||||||
|
"deposit_returned": ["returned"],
|
||||||
|
"deposit_amount": ["deposit_amount"],
|
||||||
|
"default": ["-date"],
|
||||||
|
}
|
|
@ -43,6 +43,7 @@ from users.models import User
|
||||||
|
|
||||||
from .forms import DepositForm, DepositItemForm, DelDepositItemForm
|
from .forms import DepositForm, DepositItemForm, DelDepositItemForm
|
||||||
from .models import Deposit, DepositItem
|
from .models import Deposit, DepositItem
|
||||||
|
from .utils import DepositSortTable
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -117,13 +118,45 @@ def del_deposit(request, deposit, **_kwargs):
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@can_edit(Deposit)
|
@can_view_all(Deposit)
|
||||||
def change_deposit_status(request, deposit, depositid):
|
def index_deposits(request):
|
||||||
"""View used to change a ticket's status."""
|
"""
|
||||||
deposit.returned = not deposit.solved
|
View used to display the list of all deposits.
|
||||||
deposit.save()
|
"""
|
||||||
return redirect(
|
pagination_number = GeneralOption.get_cached_value("pagination_number")
|
||||||
reverse("deposits:aff-deposit", kwargs={"depositid": str(depositid)})
|
|
||||||
|
# Get the list of all deposits, sorted according to the user's request
|
||||||
|
deposits_list = Deposit.objects.select_related("user", "item", "payment_method")
|
||||||
|
deposits_list = DepositSortTable.sort(
|
||||||
|
deposits_list,
|
||||||
|
request.GET.get("col"),
|
||||||
|
request.GET.get("order"),
|
||||||
|
DepositSortTable.DEPOSIT_INDEX,
|
||||||
|
)
|
||||||
|
nbr_deposits = deposits_list.count()
|
||||||
|
|
||||||
|
# Split it into 2: the list of those which have not yet been returned...
|
||||||
|
lent_deposits_list = deposits_list.filter(returned=False)
|
||||||
|
nbr_deposits_lent = lent_deposits_list.count()
|
||||||
|
lent_deposits_list = re2o_paginator(
|
||||||
|
request, lent_deposits_list, pagination_number, page_arg="lpage"
|
||||||
|
)
|
||||||
|
|
||||||
|
# ... and the list of those that have already been returned
|
||||||
|
returned_deposits_list = deposits_list.filter(returned=True)
|
||||||
|
returned_deposits_list = re2o_paginator(
|
||||||
|
request, returned_deposits_list, pagination_number, page_arg="rpage"
|
||||||
|
)
|
||||||
|
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"deposits/index_deposits.html",
|
||||||
|
{
|
||||||
|
"lent_deposits_list": lent_deposits_list,
|
||||||
|
"returned_deposits_list": returned_deposits_list,
|
||||||
|
"nbr_deposits": nbr_deposits,
|
||||||
|
"nbr_deposits_lent": nbr_deposits_lent,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,7 +242,15 @@ def index_deposit_item(request):
|
||||||
# Canonic views for optional apps
|
# Canonic views for optional apps
|
||||||
def aff_profil(request, user):
|
def aff_profil(request, user):
|
||||||
"""View used to display the deposits on a user's profile."""
|
"""View used to display the deposits on a user's profile."""
|
||||||
deposits_list = Deposit.objects.filter(user=user).all().order_by("-date")
|
deposits_list = Deposit.objects.filter(user=user).select_related(
|
||||||
|
"user", "item", "payment_method"
|
||||||
|
)
|
||||||
|
deposits_list = DepositSortTable.sort(
|
||||||
|
deposits_list,
|
||||||
|
request.GET.get("col"),
|
||||||
|
request.GET.get("order"),
|
||||||
|
DepositSortTable.DEPOSIT_INDEX,
|
||||||
|
)
|
||||||
pagination_number = GeneralOption.get_cached_value("pagination_large_number")
|
pagination_number = GeneralOption.get_cached_value("pagination_large_number")
|
||||||
|
|
||||||
deposits = re2o_paginator(request, deposits_list, pagination_number)
|
deposits = re2o_paginator(request, deposits_list, pagination_number)
|
||||||
|
|
Loading…
Reference in a new issue