1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-07-05 10:34:09 +02:00

Automatically create mailing lists

This commit is contained in:
Yohann D'ANELLO
2020-10-09 13:49:09 +02:00
parent 798c8db781
commit 92e66d75ab
5 changed files with 36 additions and 2 deletions

View File

@ -8,6 +8,8 @@ from django.utils.crypto import get_random_string
from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy as _
from corres2math.lists import get_sympa_client
class Team(models.Model):
name = models.CharField(
@ -36,9 +38,22 @@ class Team(models.Model):
default=False,
)
def create_mailing_list(self):
get_sympa_client().create_list(
f"equipe-{self.trigram.lower()}",
f"Équipe {self.name} ({self.trigram})",
"hotline", # TODO Use a custom sympa template
f"Liste de diffusion pour contacter l'équipe {self.name} des Correspondances",
"education",
)
def delete_mailing_list(self):
get_sympa_client().delete_list(f"equipe-{self.trigram}")
def save(self, *args, **kwargs):
if not self.access_code:
self.access_code = get_random_string(6)
self.create_mailing_list()
return super().save(*args, **kwargs)
def __str__(self):