1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-21 15:18:23 +02:00

We can only register during the first phase

This commit is contained in:
Yohann D'ANELLO
2020-11-15 01:40:20 +01:00
parent ece1e800ab
commit d3e18a8fbb
4 changed files with 31 additions and 7 deletions

View File

@ -65,7 +65,7 @@ class Team(models.Model):
"education",
raise_error=False,
)
if self.pk and self.participation.valid:
if self.pk and self.participation.valid: # pragma: no cover
get_sympa_client().subscribe(self.email, "equipes", False, f"Equipe {self.name}")
get_sympa_client().subscribe(self.email, f"probleme-{self.participation.problem}", False,
f"Equipe {self.name}")
@ -76,7 +76,7 @@ class Team(models.Model):
"""
Drop the Sympa mailing list, if the team is empty or if the trigram changed.
"""
if self.participation.valid:
if self.participation.valid: # pragma: no cover
get_sympa_client().unsubscribe(self.email, "equipes", False)
get_sympa_client().unsubscribe(self.email, f"probleme-{self.participation.problem}", False)
else:
@ -292,10 +292,8 @@ class Phase(models.Model):
qs = Phase.objects.filter(start__lte=timezone.now(), end__gte=timezone.now())
if qs.exists():
return qs.get()
qs = Phase.objects.order_by("phase_number").all()
if timezone.now() < qs.first().start:
return qs.first()
return qs.last()
qs = Phase.objects.filter(start__lte=timezone.now()).order_by("phase_number").all()
return qs.last() if qs.exists() else None
def __str__(self):
return _("Phase {phase_number:d} starts on {start:%Y-%m-%d %H:%M} and ends on {end:%Y-%m-%d %H:%M}")\

View File

@ -575,7 +575,7 @@ class TestStudentParticipation(TestCase):
for i in range(1, 5):
Phase.objects.filter(phase_number=i).update(start=timezone.now() + timedelta(days=2 * i),
end=timezone.now() + timedelta(days=2 * i + 1))
self.assertEqual(Phase.current_phase().phase_number, 1)
self.assertEqual(Phase.current_phase(), None)
# We are after the end
for i in range(1, 5):