3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-11-22 11:23:11 +00:00

Résolution du problème de Foulques

This commit is contained in:
Yoann Pétri 2019-02-25 11:13:42 +01:00
parent 3025ed6cf4
commit f9cea66804

View file

@ -47,12 +47,11 @@ class Product(models.Model):
def user_ranking(self, pk):
user = User.objects.get(pk=pk)
consumptions = ConsumptionHistory.objects.filter(customer=user).filter(product=self)
# add menu
nb = 0
for consumption in consumptions:
nb += consumption.quantity
return (user, nb)
consumptions = Consumption.objects.filter(customer=user).filter(product=self)
if consumptions:
return (user, consumptions[0].quantity)
else:
return (user, 0)
@property
def ranking(self):