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 ""
|
||||
"Project-Id-Version: PACKAGE VERSION\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"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -31,11 +31,19 @@ msgstr ""
|
|||
"Content-Transfer-Encoding: 8bit\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"
|
||||
msgstr "Caution rendue"
|
||||
|
||||
#: deposits/forms.py:76
|
||||
#: deposits/forms.py:79
|
||||
msgid "Current deposit items"
|
||||
msgstr "Articles sous cautions actuels"
|
||||
|
||||
|
@ -51,7 +59,7 @@ msgstr "rendu"
|
|||
msgid "deposit amount"
|
||||
msgstr "montant de la caution"
|
||||
|
||||
#: deposits/models.py:60 deposits/views.py:113
|
||||
#: deposits/models.py:60 deposits/views.py:114
|
||||
msgid "deposit"
|
||||
msgstr "caution"
|
||||
|
||||
|
@ -89,36 +97,29 @@ msgstr "article"
|
|||
msgid "deposit items"
|
||||
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_deposits.html:37
|
||||
#: deposits/templates/deposits/aff_deposits.html:44
|
||||
msgid "Amount"
|
||||
msgstr "Montant"
|
||||
|
||||
#: deposits/templates/deposits/aff_deposits.html:35
|
||||
#: deposits/templates/deposits/aff_deposits.html:36
|
||||
msgid "User"
|
||||
msgstr "Utilisateur"
|
||||
|
||||
#: deposits/templates/deposits/aff_deposits.html:36
|
||||
#: deposits/templates/deposits/aff_deposits.html:40
|
||||
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
|
||||
#: deposits/templates/deposits/aff_deposits.html:52
|
||||
msgid "Date"
|
||||
msgstr "Date"
|
||||
|
||||
#: deposits/templates/deposits/aff_deposits.html:40
|
||||
#: deposits/templates/deposits/aff_deposits.html:56
|
||||
msgid "Returned"
|
||||
msgstr "Rendu"
|
||||
|
||||
#: deposits/templates/deposits/aff_profil.html:29
|
||||
#: deposits/templates/deposits/navbar.html:25
|
||||
msgid "Deposits"
|
||||
msgstr "Cautions"
|
||||
|
||||
|
@ -143,7 +144,7 @@ msgstr ""
|
|||
"Attention: voulez-vous vraiment supprimer cet objet %(objet_name)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"
|
||||
msgstr "Confirmer"
|
||||
|
||||
|
@ -151,12 +152,12 @@ msgstr "Confirmer"
|
|||
msgid "Create or edit deposit"
|
||||
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"
|
||||
msgstr "Ajouter"
|
||||
|
||||
#: deposits/templates/deposits/index_deposit_item.html:27
|
||||
#: deposits/templates/deposits/navbar.html:24
|
||||
#: deposits/templates/deposits/navbar.html:33
|
||||
msgid "Deposit items"
|
||||
msgstr "Articles sous caution"
|
||||
|
||||
|
@ -172,54 +173,82 @@ msgstr "Ajouter un article"
|
|||
msgid "Delete one or several deposit items"
|
||||
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."
|
||||
msgstr "La caution a été crée."
|
||||
|
||||
#: deposits/views.py:70
|
||||
#: deposits/views.py:71
|
||||
msgid "New deposit"
|
||||
msgstr "Nouvelle caution"
|
||||
|
||||
#: deposits/views.py:88
|
||||
#: deposits/views.py:89
|
||||
msgid "The deposit was edited."
|
||||
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"
|
||||
msgstr "Modifier"
|
||||
|
||||
#: deposits/views.py:95
|
||||
#: deposits/views.py:96
|
||||
msgid "Edit deposit"
|
||||
msgstr "Modifier la caution"
|
||||
|
||||
#: deposits/views.py:110
|
||||
#: deposits/views.py:111
|
||||
msgid "The deposit was deleted."
|
||||
msgstr "La caution a été supprimée."
|
||||
|
||||
#: deposits/views.py:139
|
||||
#: deposits/views.py:168
|
||||
msgid "The item was created."
|
||||
msgstr "L'article a été créé."
|
||||
|
||||
#: deposits/views.py:145
|
||||
#: deposits/views.py:174
|
||||
msgid "New deposit item"
|
||||
msgstr "Nouvel article"
|
||||
|
||||
#: deposits/views.py:162
|
||||
#: deposits/views.py:191
|
||||
msgid "The item was edited."
|
||||
msgstr "L'article a été modifié."
|
||||
|
||||
#: deposits/views.py:168
|
||||
#: deposits/views.py:197
|
||||
msgid "Edit deposit item"
|
||||
msgstr "Modifier l'article"
|
||||
|
||||
#: deposits/views.py:185
|
||||
#: deposits/views.py:214
|
||||
msgid "The items were deleted."
|
||||
msgstr "Les articles ont été supprimés."
|
||||
|
||||
#: deposits/views.py:190
|
||||
#: deposits/views.py:219
|
||||
msgid "Delete"
|
||||
msgstr "Supprimer"
|
||||
|
||||
#: deposits/views.py:191
|
||||
#: deposits/views.py:220
|
||||
msgid "Delete deposit item"
|
||||
msgstr "Supprimer l'article"
|
||||
|
|
|
@ -32,13 +32,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{% trans "User" %}</th>
|
||||
<th scope="col">{% trans "Item" %}</th>
|
||||
<th scope="col">{% trans "Amount" %}</th>
|
||||
<th scope="col">{% trans "Payment method" %}</th>
|
||||
<th scope="col">{% trans "Date" %}</th>
|
||||
<th scope="col">{% trans "Returned" %}</th>
|
||||
<th scope="col"></th>
|
||||
<th>
|
||||
{% trans "User" as tr_user %}
|
||||
{% include 'buttons/sort.html' with prefix='deposit' col="user" text=tr_user %}
|
||||
</th>
|
||||
<th>
|
||||
{% trans "Item" as tr_item %}
|
||||
{% 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>
|
||||
{% for deposit in deposits_list %}
|
||||
<tr>
|
||||
|
@ -64,7 +82,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
</thead>
|
||||
</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" %}
|
||||
{% endif %}
|
||||
</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 %}
|
||||
|
||||
{% 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("edit_deposit/<int:depositid>", views.edit_deposit, name="edit-deposit"),
|
||||
path("del_deposit/<int:depositid>", views.del_deposit, name="del-deposit"),
|
||||
path(
|
||||
"change_deposit_status/<int:depositid>",
|
||||
views.change_deposit_status,
|
||||
name="change-deposit-status",
|
||||
),
|
||||
path("index_deposits", views.index_deposits, name="index-deposits"),
|
||||
path("add_deposit_item", views.add_deposit_item, name="add-deposit-item"),
|
||||
path(
|
||||
"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 .models import Deposit, DepositItem
|
||||
from .utils import DepositSortTable
|
||||
|
||||
|
||||
@login_required
|
||||
|
@ -117,13 +118,45 @@ def del_deposit(request, deposit, **_kwargs):
|
|||
|
||||
|
||||
@login_required
|
||||
@can_edit(Deposit)
|
||||
def change_deposit_status(request, deposit, depositid):
|
||||
"""View used to change a ticket's status."""
|
||||
deposit.returned = not deposit.solved
|
||||
deposit.save()
|
||||
return redirect(
|
||||
reverse("deposits:aff-deposit", kwargs={"depositid": str(depositid)})
|
||||
@can_view_all(Deposit)
|
||||
def index_deposits(request):
|
||||
"""
|
||||
View used to display the list of all deposits.
|
||||
"""
|
||||
pagination_number = GeneralOption.get_cached_value("pagination_number")
|
||||
|
||||
# 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
|
||||
def aff_profil(request, user):
|
||||
"""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")
|
||||
|
||||
deposits = re2o_paginator(request, deposits_list, pagination_number)
|
||||
|
|
Loading…
Reference in a new issue