fix free colle

This commit is contained in:
Valentin Moguérou 2024-05-03 15:58:37 +02:00
parent 9dbaaf35c9
commit d080b92aec
2 changed files with 10 additions and 3 deletions

View File

@ -314,6 +314,10 @@ class Colle(models.Model):
& ~Q(id__in=swaps.filter(enroll=False).values("student_id")) & ~Q(id__in=swaps.filter(enroll=False).values("student_id"))
) )
def is_attendee(self, student):
return self.final_group().contains(student)
def volume(self): def volume(self):
""" """
Renvoie le nombre d'étudiants inscrits à la colle en tenant compte des swaps. Renvoie le nombre d'étudiants inscrits à la colle en tenant compte des swaps.

View File

@ -254,9 +254,12 @@ def amend(request, colle_id, do_enroll):
.get(id=colle_id, slot__term__cls=student.cls) .get(id=colle_id, slot__term__cls=student.cls)
.amend(enroll=True, student=student, notify=True)) .amend(enroll=True, student=student, notify=True))
else: else:
(Colle.objects colle = Colle.objects.get(id=colle_id)
.get(id=colle_id, groups__student=student)
.amend(enroll=False, student=student, notify=True)) if colle.is_attendee(student):
colle.amend(enroll=False, student=student, notify=True)
else:
raise Exception("vous n'êtes pas dans la colle...")
@require_POST @require_POST