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 %} {% block content %}
{% if profile.permanencies %} {% if profile.permanencies %}
<h3>{% trans %}Permanencies{% endtrans %}</h3>
<div> <div>
<h3>{% trans %}Permanencies{% endtrans %}</h3>
<p>Total: {{ total_perm_time }}</p> <p>Total: {{ total_perm_time }}</p>
<p>Foyer: {{ total_foyer_time }}</p> <p>Foyer: {{ total_foyer_time }}</p>
<p>MDE: {{ total_mde_time }}</p> <p>MDE: {{ total_mde_time }}</p>
<p>La Gommette: {{ total_gommette_time }}</p> <p>La Gommette: {{ total_gommette_time }}</p>
</div> </div>
{% endif %} {% endif %}
<h3>{% trans %}Buyings{% endtrans %}</h3>
<div> <div>
<h3>{% trans %}Buyings{% endtrans %}</h3>
<p>Foyer: {{ total_foyer_buyings }} €</p> <p>Foyer: {{ total_foyer_buyings }} €</p>
<p>MDE: {{ total_mde_buyings }} €</p> <p>MDE: {{ total_mde_buyings }} €</p>
<p>La Gommette: {{ total_gommette_buyings }} €</p> <p>La Gommette: {{ total_gommette_buyings }} €</p>
</div> </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 %} {% endblock %}

View File

@ -222,7 +222,8 @@ class UserStatsView(UserTabsMixin, CanViewMixin, DetailView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs = super(UserStatsView, self).get_context_data(**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() foyer = Counter.objects.filter(name="Foyer").first()
mde = Counter.objects.filter(name="MDE").first() mde = Counter.objects.filter(name="MDE").first()
gommette = Counter.objects.filter(name="La Gommette").first() gommette = Counter.objects.filter(name="La Gommette").first()
@ -237,6 +238,8 @@ class UserStatsView(UserTabsMixin, CanViewMixin, DetailView):
date__gte=semester_start)]) date__gte=semester_start)])
kwargs['total_gommette_buyings'] = sum([b.unit_price*b.quantity for b in kwargs['total_gommette_buyings'] = sum([b.unit_price*b.quantity for b in
self.object.customer.buyings.filter(counter=gommette, date__gte=semester_start)]) 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 return kwargs
class UserMiniView(CanViewMixin, DetailView): class UserMiniView(CanViewMixin, DetailView):

Binary file not shown.

View File

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