3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-12-26 00:43:46 +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): def user_ranking(self, pk):
user = User.objects.get(pk=pk) user = User.objects.get(pk=pk)
consumptions = ConsumptionHistory.objects.filter(customer=user).filter(product=self) consumptions = Consumption.objects.filter(customer=user).filter(product=self)
# add menu if consumptions:
nb = 0 return (user, consumptions[0].quantity)
for consumption in consumptions: else:
nb += consumption.quantity return (user, 0)
return (user, nb)
@property @property
def ranking(self): def ranking(self):