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:
@ -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):
|
||||
|
Reference in New Issue
Block a user