mirror of
https://github.com/nanoy42/coope
synced 2024-11-25 22:22:27 +00:00
Résolution du problème de Foulques
This commit is contained in:
parent
3025ed6cf4
commit
f9cea66804
1 changed files with 5 additions and 6 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue