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.
|
||||
"""
|
||||
counter, created = cls.objects.get_or_create(
|
||||
user=user, matiere=matiere)
|
||||
user=user,
|
||||
matiere=matiere,
|
||||
)
|
||||
if created:
|
||||
mincount = (
|
||||
cls.objects.filter(matiere=matiere).exclude(user=user)
|
||||
.aggregate(Min('count'))
|
||||
['count__min']
|
||||
)
|
||||
counter.count = mincount
|
||||
counter.count = mincount or 0
|
||||
counter.save()
|
||||
return counter
|
||||
|
||||
|
|
Loading…
Reference in a new issue