mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-23 23:08:50 +02:00
Add migrations for ETEAM
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
@ -38,13 +38,13 @@ class Team(models.Model):
|
||||
)
|
||||
|
||||
trigram = models.CharField(
|
||||
max_length=settings.TEAM_CODE_LENGTH,
|
||||
max_length=4,
|
||||
verbose_name=_("code"),
|
||||
help_text=format_lazy(_("The code must be composed of {nb_letters} uppercase letters."),
|
||||
nb_letters=settings.TEAM_CODE_LENGTH),
|
||||
unique=True,
|
||||
validators=[
|
||||
RegexValidator("^[A-Z]{" + str(settings.TEAM_CODE_LENGTH) + "}$"),
|
||||
RegexValidator("^[A-Z]{3}[A-Z]*$"),
|
||||
RegexValidator(fr"^(?!{'|'.join(f'{t}$' for t in settings.FORBIDDEN_TRIGRAMS)})",
|
||||
message=_("This team code is forbidden.")),
|
||||
],
|
||||
@ -236,6 +236,12 @@ class Team(models.Model):
|
||||
get_sympa_client().unsubscribe(self.email, "equipes-non-valides", False)
|
||||
get_sympa_client().delete_list(f"equipe-{self.trigram}")
|
||||
|
||||
def clean(self):
|
||||
if len(self.trigram) != settings.TEAM_CODE_LENGTH:
|
||||
raise ValidationError({'trigram': _("The team code must be composed of {nb_letters} uppercase letters.")},
|
||||
params={'nb_letters': settings.TEAM_CODE_LENGTH})
|
||||
return super().clean()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.access_code:
|
||||
# if the team got created, generate the access code, create the contact mailing list
|
||||
|
Reference in New Issue
Block a user