Add product top 10

This commit is contained in:
Skia 2016-09-22 11:09:15 +02:00
parent 24d744ee9c
commit 7a2985b186
4 changed files with 92 additions and 66 deletions

View File

@ -6,20 +6,37 @@
{% block content %}
{% if profile.permanencies %}
<div>
<h3>{% trans %}Permanencies{% endtrans %}</h3>
<div>
<p>Total: {{ total_perm_time }}</p>
<p>Foyer: {{ total_foyer_time }}</p>
<p>MDE: {{ total_mde_time }}</p>
<p>La Gommette: {{ total_gommette_time }}</p>
</div>
{% endif %}
<div>
<h3>{% trans %}Buyings{% endtrans %}</h3>
<div>
<p>Foyer: {{ total_foyer_buyings }} €</p>
<p>MDE: {{ total_mde_buyings }} €</p>
<p>La Gommette: {{ total_gommette_buyings }} €</p>
</div>
<h3>{% trans %}Product top 10{% endtrans %}</h3>
<table>
<thead>
<tr>
<td>{% trans %}Product{% endtrans %}</td>
<td>{% trans %}Quantity{% endtrans %}</td>
</tr>
</thead>
<tbody>
{% for p in top_product %}
<tr>
<td>{{ p['product__name'] }}</td>
<td>{{ p['product_sum'] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -222,7 +222,8 @@ class UserStatsView(UserTabsMixin, CanViewMixin, DetailView):
def get_context_data(self, **kwargs):
kwargs = super(UserStatsView, self).get_context_data(**kwargs)
from counter.models import Counter
from counter.models import Counter, Product, Selling
from django.db.models import Sum
foyer = Counter.objects.filter(name="Foyer").first()
mde = Counter.objects.filter(name="MDE").first()
gommette = Counter.objects.filter(name="La Gommette").first()
@ -237,6 +238,8 @@ class UserStatsView(UserTabsMixin, CanViewMixin, DetailView):
date__gte=semester_start)])
kwargs['total_gommette_buyings'] = sum([b.unit_price*b.quantity for b in
self.object.customer.buyings.filter(counter=gommette, date__gte=semester_start)])
kwargs['top_product'] = self.object.customer.buyings.values('product__name').annotate(
product_sum=Sum('quantity')).exclude(product_sum=None).order_by('-product_sum').all()[:10]
return kwargs
class UserMiniView(CanViewMixin, DetailView):

Binary file not shown.

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-21 12:42+0200\n"
"POT-Creation-Date: 2016-09-22 11:08+0200\n"
"PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n"
@ -85,12 +85,12 @@ msgstr "Compte club"
msgid "%(club_account)s on %(bank_account)s"
msgstr "%(club_account)s sur %(bank_account)s"
#: accounting/models.py:130 club/models.py:146 counter/models.py:330
#: accounting/models.py:130 club/models.py:146 counter/models.py:331
#: launderette/models.py:122
msgid "start date"
msgstr "date de début"
#: accounting/models.py:131 club/models.py:147 counter/models.py:331
#: accounting/models.py:131 club/models.py:147 counter/models.py:332
msgid "end date"
msgstr "date de fin"
@ -103,7 +103,7 @@ msgid "club account"
msgstr "compte club"
#: accounting/models.py:135 accounting/models.py:178 counter/models.py:25
#: counter/models.py:218
#: counter/models.py:219
msgid "amount"
msgstr "montant"
@ -124,16 +124,16 @@ msgid "journal"
msgstr "classeur"
#: accounting/models.py:179 core/models.py:461 core/models.py:739
#: counter/models.py:221 counter/models.py:264 counter/models.py:347
#: counter/models.py:222 counter/models.py:265 counter/models.py:348
#: eboutic/models.py:15 eboutic/models.py:48
msgid "date"
msgstr "date"
#: accounting/models.py:180 counter/models.py:348
#: accounting/models.py:180 counter/models.py:349
msgid "comment"
msgstr "commentaire"
#: accounting/models.py:181 counter/models.py:222 counter/models.py:265
#: accounting/models.py:181 counter/models.py:223 counter/models.py:266
#: subscription/models.py:57
msgid "payment method"
msgstr "méthode de paiement"
@ -232,7 +232,7 @@ msgstr "code"
msgid "An accounting type code contains only numbers"
msgstr "Un code comptable ne contient que des numéros"
#: accounting/models.py:282 accounting/models.py:308 counter/models.py:256
#: accounting/models.py:282 accounting/models.py:308 counter/models.py:257
msgid "label"
msgstr "intitulé"
@ -272,7 +272,7 @@ msgstr "Liste des types comptable"
#: accounting/templates/accounting/journal_details.jinja:9
#: accounting/templates/accounting/operation_edit.jinja:9
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:9
#: core/templates/core/user_tools.jinja:41
#: core/templates/core/user_tools.jinja:42
msgid "Accounting"
msgstr "Comptabilité"
@ -291,7 +291,7 @@ msgstr "Il n'y a pas de types comptable dans ce site web."
#: accounting/templates/accounting/bank_account_details.jinja:4
#: accounting/templates/accounting/bank_account_details.jinja:13
#: core/templates/core/user_tools.jinja:48
#: core/templates/core/user_tools.jinja:49
msgid "Bank account: "
msgstr "Compte en banque : "
@ -327,7 +327,7 @@ msgstr "Nouveau compte club"
#: accounting/templates/accounting/club_account_details.jinja:53
#: accounting/templates/accounting/journal_details.jinja:66 club/views.py:52
#: core/templates/core/file.jinja:38 core/templates/core/page.jinja:31
#: core/templates/core/user_tools.jinja:34 core/views/user.py:151
#: core/templates/core/user_tools.jinja:35 core/views/user.py:151
#: counter/templates/counter/counter_list.jinja:17
#: counter/templates/counter/counter_list.jinja:32
#: counter/templates/counter/counter_list.jinja:47
@ -545,7 +545,7 @@ msgstr "Vous ne pouvez pas faire de boucles dans les clubs"
msgid "A club with that unix_name already exists"
msgstr "Un club avec ce nom UNIX existe déjà."
#: club/models.py:144 counter/models.py:328 counter/models.py:345
#: club/models.py:144 counter/models.py:329 counter/models.py:346
#: eboutic/models.py:14 eboutic/models.py:47 launderette/models.py:89
#: launderette/models.py:126
msgid "user"
@ -675,6 +675,7 @@ msgstr "Intitulé"
#: club/templates/club/club_sellings.jinja:23
#: core/templates/core/user_account_detail.jinja:50
#: core/templates/core/user_stats.jinja:28
msgid "Quantity"
msgstr "Quantité"
@ -693,7 +694,7 @@ msgid "Payment method"
msgstr "Méthode de paiement"
#: club/templates/club/club_tools.jinja:4
#: core/templates/core/user_tools.jinja:60
#: core/templates/core/user_tools.jinja:61
msgid "Club tools"
msgstr "Outils club"
@ -735,7 +736,7 @@ msgstr "Date de début"
msgid "End date"
msgstr "Date de fin"
#: club/views.py:172
#: club/views.py:172 core/templates/core/user_stats.jinja:27
msgid "Product"
msgstr "Produit"
@ -1019,8 +1020,8 @@ msgid "A user with that username already exists"
msgstr "Un utilisateur de ce nom d'utilisateur existe déjà"
#: core/models.py:396 core/templates/core/macros.jinja:17
#: core/templates/core/user_detail.jinja:15
#: core/templates/core/user_detail.jinja:17
#: core/templates/core/user_detail.jinja:14
#: core/templates/core/user_detail.jinja:16
#: core/templates/core/user_edit.jinja:16
msgid "Profile"
msgstr "Profil"
@ -1348,12 +1349,12 @@ msgid "Lost password?"
msgstr "Mot de passe perdu ?"
#: core/templates/core/macros.jinja:27
#: core/templates/core/user_detail.jinja:28
#: core/templates/core/user_detail.jinja:27
msgid "Born: "
msgstr "Né le : "
#: core/templates/core/macros.jinja:31
#: core/templates/core/user_detail.jinja:49
#: core/templates/core/user_detail.jinja:48
msgid "Promo: "
msgstr "Promo : "
@ -1623,25 +1624,25 @@ msgstr "Articles"
msgid "%(user_name)s's profile"
msgstr "Profil de %(user_name)s"
#: core/templates/core/user_detail.jinja:34
#: core/templates/core/user_detail.jinja:33
msgid "Option: "
msgstr "Filière : "
#: core/templates/core/user_detail.jinja:59
#: core/templates/core/user_detail.jinja:58
#, python-format
msgid "Subscribed until %(subscription_end)s"
msgstr "Cotisant jusqu'au %(subscription_end)s"
#: core/templates/core/user_detail.jinja:61
#: core/templates/core/user_detail.jinja:60
#: core/templates/core/user_edit.jinja:39
msgid "Account number: "
msgstr "Numero de compte : "
#: core/templates/core/user_detail.jinja:68
#: core/templates/core/user_detail.jinja:67
msgid "Not subscribed"
msgstr "Non cotisant"
#: core/templates/core/user_detail.jinja:70
#: core/templates/core/user_detail.jinja:69
#: subscription/templates/subscription/subscription.jinja:4
#: subscription/templates/subscription/subscription.jinja:8
msgid "New subscription"
@ -1718,14 +1719,18 @@ msgstr "Liste d'utilisateurs"
msgid "%(user_name)s's stats"
msgstr "Stats de %(user_name)s"
#: core/templates/core/user_stats.jinja:10
#: core/templates/core/user_stats.jinja:9
msgid "Permanencies"
msgstr "Permanences"
#: core/templates/core/user_stats.jinja:18
#: core/templates/core/user_stats.jinja:17
msgid "Buyings"
msgstr "Achats"
#: core/templates/core/user_stats.jinja:23
msgid "Product top 10"
msgstr "Top 10 produits"
#: core/templates/core/user_tools.jinja:4
#, python-format
msgid "%(user_name)s's tools"
@ -1743,48 +1748,53 @@ msgstr "Gestion de Sith"
msgid "Groups"
msgstr "Groupes"
#: core/templates/core/user_tools.jinja:17
#: core/templates/core/user_tools.jinja:15
#: rootplace/templates/rootplace/merge.jinja:4
msgid "Merge users"
msgstr "Fusionner deux utilisateurs"
#: core/templates/core/user_tools.jinja:18
msgid "Subscriptions"
msgstr "Cotisations"
#: core/templates/core/user_tools.jinja:22 counter/views.py:395
#: core/templates/core/user_tools.jinja:23 counter/views.py:395
#: counter/views.py:534
msgid "Counters"
msgstr "Comptoirs"
#: core/templates/core/user_tools.jinja:25
#: core/templates/core/user_tools.jinja:26
msgid "General management"
msgstr "Gestion générale"
#: core/templates/core/user_tools.jinja:26
#: core/templates/core/user_tools.jinja:27
msgid "General counters management"
msgstr "Gestion générale des comptoirs"
#: core/templates/core/user_tools.jinja:27
#: core/templates/core/user_tools.jinja:28
msgid "Products management"
msgstr "Gestion des produits"
#: core/templates/core/user_tools.jinja:28
#: core/templates/core/user_tools.jinja:29
msgid "Product types management"
msgstr "Gestion des types de produit"
#: core/templates/core/user_tools.jinja:29
#: core/templates/core/user_tools.jinja:30
#: counter/templates/counter/cash_summary_list.jinja:18 counter/views.py:415
msgid "Cash register summaries"
msgstr "Relevés de caisse"
#: core/templates/core/user_tools.jinja:35 core/views/user.py:145
#: core/templates/core/user_tools.jinja:36 core/views/user.py:145
#: counter/templates/counter/counter_list.jinja:18
#: counter/templates/counter/counter_list.jinja:33
#: counter/templates/counter/counter_list.jinja:48
msgid "Stats"
msgstr "Stats"
#: core/templates/core/user_tools.jinja:44
#: core/templates/core/user_tools.jinja:45
msgid "General accounting"
msgstr "Comptabilité générale"
#: core/templates/core/user_tools.jinja:53
#: core/templates/core/user_tools.jinja:54
msgid "Club account: "
msgstr "Compte club : "
@ -1846,7 +1856,7 @@ msgstr "Fillot"
msgid "Select user"
msgstr "Choisir un utilisateur"
#: core/views/user.py:272
#: core/views/user.py:275
msgid "User already has a profile picture"
msgstr "L'utilisateur a déjà une photo de profil"
@ -1939,73 +1949,77 @@ msgstr "Eboutic"
msgid "sellers"
msgstr "vendeurs"
#: counter/models.py:131 counter/models.py:329 counter/models.py:346
#: counter/models.py:129 launderette/models.py:125
msgid "token"
msgstr "jeton"
#: counter/models.py:132 counter/models.py:330 counter/models.py:347
#: launderette/models.py:16
msgid "counter"
msgstr "comptoir"
#: counter/models.py:224
#: counter/models.py:225
msgid "bank"
msgstr "banque"
#: counter/models.py:226 counter/models.py:267
#: counter/models.py:227 counter/models.py:268
msgid "is validated"
msgstr "est validé"
#: counter/models.py:229
#: counter/models.py:230
msgid "refilling"
msgstr "rechargement"
#: counter/models.py:260 eboutic/models.py:103
#: counter/models.py:261 eboutic/models.py:103
msgid "unit price"
msgstr "prix unitaire"
#: counter/models.py:261 counter/models.py:379 eboutic/models.py:104
#: counter/models.py:262 counter/models.py:380 eboutic/models.py:104
msgid "quantity"
msgstr "quantité"
#: counter/models.py:266
#: counter/models.py:267
msgid "Sith account"
msgstr "Compte utilisateur"
#: counter/models.py:266 sith/settings.py:271 sith/settings.py:276
#: counter/models.py:267 sith/settings.py:271 sith/settings.py:276
#: sith/settings.py:298
msgid "Credit card"
msgstr "Carte bancaire"
#: counter/models.py:270
#: counter/models.py:271
msgid "selling"
msgstr "vente"
#: counter/models.py:332
#: counter/models.py:333
msgid "last activity date"
msgstr "dernière activité"
#: counter/models.py:335
#: counter/models.py:336
msgid "permanency"
msgstr "permanence"
#: counter/models.py:349
#: counter/models.py:350
msgid "emptied"
msgstr "coffre vidée"
#: counter/models.py:352
#: counter/models.py:353
msgid "cash register summary"
msgstr "relevé de caisse"
#: counter/models.py:377
#: counter/models.py:378
msgid "cash summary"
msgstr "relevé"
#: counter/models.py:378
#: counter/models.py:379
msgid "value"
msgstr "valeur"
#: counter/models.py:380
#: counter/models.py:381
msgid "check"
msgstr "chèque"
#: counter/models.py:383
#: counter/models.py:384
msgid "cash register summary item"
msgstr "élément de relevé de caisse"
@ -2384,10 +2398,6 @@ msgstr "Le nom du jeton ne peut pas être vide"
msgid "machine"
msgstr "machine"
#: launderette/models.py:125
msgid "token"
msgstr "jeton"
#: launderette/templates/launderette/launderette_admin.jinja:4
msgid "Launderette admin"
msgstr "Gestion de la laverie"
@ -2474,10 +2484,6 @@ msgstr "L'utilisateur n'a pas réservé de créneau"
msgid "Token not found"
msgstr "Jeton non trouvé"
#: rootplace/templates/rootplace/merge.jinja:4
msgid "Merge users"
msgstr "Fusionner deux utilisateurs"
#: rootplace/templates/rootplace/merge.jinja:8
msgid "Merge two users"
msgstr "Fusionner deux utilisateurs"
@ -2486,11 +2492,11 @@ msgstr "Fusionner deux utilisateurs"
msgid "Merge"
msgstr "Fusion"
#: rootplace/views.py:63
#: rootplace/views.py:66
msgid "User that will be kept"
msgstr "Utilisateur qui sera conservé"
#: rootplace/views.py:64
#: rootplace/views.py:67
msgid "User that will be deleted"
msgstr "Utilisateur qui sera supprimé"