fix free colle

This commit is contained in:
Valentin Moguérou 2024-05-03 15:58:37 +02:00
parent 1f149d8252
commit 6b3d4fecc5
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"))
)
def is_attendee(self, student):
return self.final_group().contains(student)
def volume(self):
"""
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)
.amend(enroll=True, student=student, notify=True))
else:
(Colle.objects
.get(id=colle_id, groups__student=student)
.amend(enroll=False, student=student, notify=True))
colle = Colle.objects.get(id=colle_id)
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