mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-02-06 11:33:00 +00:00
Display mailing list address on team page
This commit is contained in:
parent
8c8ab4c0b7
commit
b80f98ef43
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.template.loader import render_to_string
|
from django.template.loader import render_to_string
|
||||||
@ -41,6 +42,10 @@ class Team(models.Model):
|
|||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def email(self):
|
||||||
|
return f"equipe-{self.trigram.lower()}@{os.getenv('SYMPA_HOST', 'localhost')}"
|
||||||
|
|
||||||
def create_mailing_list(self):
|
def create_mailing_list(self):
|
||||||
get_sympa_client().create_list(
|
get_sympa_client().create_list(
|
||||||
f"equipe-{self.trigram.lower()}",
|
f"equipe-{self.trigram.lower()}",
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
<dt class="col-sm-6 text-right">{% trans "Trigram:" %}</dt>
|
<dt class="col-sm-6 text-right">{% trans "Trigram:" %}</dt>
|
||||||
<dd class="col-sm-6">{{ team.trigram }}</dd>
|
<dd class="col-sm-6">{{ team.trigram }}</dd>
|
||||||
|
|
||||||
|
<dt class="col-sm-6 text-right">{% trans "Email:" %}</dt>
|
||||||
|
<dd class="col-sm-6"><a href="mailto:{{ team.email }}">{{ team.email }}</a></dd>
|
||||||
|
|
||||||
<dt class="col-sm-6 text-right">{% trans "Access code:" %}</dt>
|
<dt class="col-sm-6 text-right">{% trans "Access code:" %}</dt>
|
||||||
<dd class="col-sm-6">{{ team.access_code }}</dd>
|
<dd class="col-sm-6">{{ team.access_code }}</dd>
|
||||||
|
|
||||||
|
@ -160,17 +160,14 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
|
|||||||
mail_context = dict(team=self.object, message=form.cleaned_data["message"])
|
mail_context = dict(team=self.object, message=form.cleaned_data["message"])
|
||||||
mail_plain = render_to_string("participation/mails/team_validated.txt", mail_context)
|
mail_plain = render_to_string("participation/mails/team_validated.txt", mail_context)
|
||||||
mail_html = render_to_string("participation/mails/team_validated.html", mail_context)
|
mail_html = render_to_string("participation/mails/team_validated.html", mail_context)
|
||||||
send_mail("[Corres2math] Équipe validée", mail_plain, None,
|
send_mail("[Corres2math] Équipe validée", mail_plain, None, [self.object.email], html_message=mail_html)
|
||||||
[f"equipe-{self.object.trigram.lower()}@{os.getenv('SYMPA_HOST', 'localhost')}"],
|
|
||||||
html_message=mail_html)
|
|
||||||
elif "invalidate" in self.request.POST:
|
elif "invalidate" in self.request.POST:
|
||||||
self.object.participation.valid = None
|
self.object.participation.valid = None
|
||||||
self.object.participation.save()
|
self.object.participation.save()
|
||||||
mail_context = dict(team=self.object, message=form.cleaned_data["message"])
|
mail_context = dict(team=self.object, message=form.cleaned_data["message"])
|
||||||
mail_plain = render_to_string("participation/mails/team_not_validated.txt", mail_context)
|
mail_plain = render_to_string("participation/mails/team_not_validated.txt", mail_context)
|
||||||
mail_html = render_to_string("participation/mails/team_not_validated.html", mail_context)
|
mail_html = render_to_string("participation/mails/team_not_validated.html", mail_context)
|
||||||
send_mail("[Corres2math] Équipe non validée", mail_plain, None,
|
send_mail("[Corres2math] Équipe non validée", mail_plain, None, [self.object.email],
|
||||||
[f"equipe-{self.object.trigram.lower()}@{os.getenv('SYMPA_HOST', 'localhost')}"],
|
|
||||||
html_message=mail_html)
|
html_message=mail_html)
|
||||||
else:
|
else:
|
||||||
form.add_error(None, _("You must specify if you validate the registration or not."))
|
form.add_error(None, _("You must specify if you validate the registration or not."))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user