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:
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):
|
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):
|
||||||
|
|
Loading…
Reference in a new issue