Fix trigram validation

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-06-13 11:03:10 +02:00
parent 2627b3a9b8
commit d84db949c6
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 1 additions and 1 deletions

View File

@ -237,7 +237,7 @@ class Team(models.Model):
get_sympa_client().delete_list(f"equipe-{self.trigram}") get_sympa_client().delete_list(f"equipe-{self.trigram}")
def clean(self): def clean(self):
if len(self.trigram) != settings.TEAM_CODE_LENGTH: if self.trigram and len(self.trigram) != settings.TEAM_CODE_LENGTH:
raise ValidationError({'trigram': _("The team code must be composed of {nb_letters} uppercase letters.")}, raise ValidationError({'trigram': _("The team code must be composed of {nb_letters} uppercase letters.")},
params={'nb_letters': settings.TEAM_CODE_LENGTH}) params={'nb_letters': settings.TEAM_CODE_LENGTH})
return super().clean() return super().clean()