From 61cdc606a98ec42cadfffa924b209e1493bd465f Mon Sep 17 00:00:00 2001 From: nanoy Date: Wed, 19 Jun 2019 12:47:55 +0200 Subject: [PATCH] Fix profil --- CHANGELOG.md | 2 ++ templates/footer.html | 2 +- users/views.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e271cc3..3cdb814 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## v3.5.3 +* Fix le profil (division par 0 lorsque toutes les transactions d'un produit avaient été annulées) ## v3.5.2 * Fix la vue editKeg ## v3.5.1 diff --git a/templates/footer.html b/templates/footer.html index 29c3af8..f958c1d 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -42,6 +42,6 @@
  • Facebook
  • - + diff --git a/users/views.py b/users/views.py index cda384a..87b849b 100644 --- a/users/views.py +++ b/users/views.py @@ -141,7 +141,7 @@ def profile(request, pk): products = [] quantities = [] for k in range(tot): - if quantities_pre[k]/totQ >= 0.01: + if totQ > 0 and quantities_pre[k]/totQ >= 0.01: products.append(products_pre[k]) quantities.append(quantities_pre[k]) lastConsumptions = ConsumptionHistory.objects.filter(customer=user).order_by('-date')[:10] @@ -756,4 +756,4 @@ class NonAdminUserAutocomplete(autocomplete.Select2QuerySetView): qs = User.objects.filter(is_staff=False) if self.q: qs = qs.filter(Q(username__icontains=self.q) | Q(first_name__icontains=self.q) | Q(last_name__icontains=self.q)) - return qs \ No newline at end of file + return qs