forked from DGNum/gestioCOF
PetitCoursAttributionCounter defaults to 0
This commit is contained in:
parent
8e8e9aa076
commit
a07b5308a3
1 changed files with 4 additions and 2 deletions
|
@ -157,14 +157,16 @@ class PetitCoursAttributionCounter(models.Model):
|
||||||
compteurs de tout le monde.
|
compteurs de tout le monde.
|
||||||
"""
|
"""
|
||||||
counter, created = cls.objects.get_or_create(
|
counter, created = cls.objects.get_or_create(
|
||||||
user=user, matiere=matiere)
|
user=user,
|
||||||
|
matiere=matiere,
|
||||||
|
)
|
||||||
if created:
|
if created:
|
||||||
mincount = (
|
mincount = (
|
||||||
cls.objects.filter(matiere=matiere).exclude(user=user)
|
cls.objects.filter(matiere=matiere).exclude(user=user)
|
||||||
.aggregate(Min('count'))
|
.aggregate(Min('count'))
|
||||||
['count__min']
|
['count__min']
|
||||||
)
|
)
|
||||||
counter.count = mincount
|
counter.count = mincount or 0
|
||||||
counter.save()
|
counter.save()
|
||||||
return counter
|
return counter
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue