Send mails to organizers properly
This commit is contained in:
parent
f9dc0e57ad
commit
faba118955
|
@ -110,6 +110,21 @@ class Tournament(models.Model):
|
||||||
verbose_name = _("tournament")
|
verbose_name = _("tournament")
|
||||||
verbose_name_plural = _("tournaments")
|
verbose_name_plural = _("tournaments")
|
||||||
|
|
||||||
|
def send_mail_to_organizers(self, template_name, subject="Contact TFJM²", **kwargs):
|
||||||
|
context = kwargs
|
||||||
|
context["tournament"] = self
|
||||||
|
for user in self.organizers.all():
|
||||||
|
context["user"] = user
|
||||||
|
message = render_to_string("mail_templates/" + template_name + ".txt", context=context)
|
||||||
|
message_html = render_to_string("mail_templates/" + template_name + ".html", context=context)
|
||||||
|
send_mail(subject, message, "contact@tfjm.org", [user.email], html_message=message_html)
|
||||||
|
from member.models import TFJMUser
|
||||||
|
for user in TFJMUser.objects.get(is_superuser=True).all():
|
||||||
|
context["user"] = user
|
||||||
|
message = render_to_string("mail_templates/" + template_name + ".txt", context=context)
|
||||||
|
message_html = render_to_string("mail_templates/" + template_name + ".html", context=context)
|
||||||
|
send_mail(subject, message, "contact@tfjm.org", [user.email], html_message=message_html)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ class TeamDetailView(LoginRequiredMixin, DetailView):
|
||||||
elif "request_validation" in request.POST and request.user.participates:
|
elif "request_validation" in request.POST and request.user.participates:
|
||||||
team.validation_status = "1waiting"
|
team.validation_status = "1waiting"
|
||||||
team.save()
|
team.save()
|
||||||
team.send_mail("request_validation", "Demande de validation TFJM²")
|
team.tournament.send_mail_to_organizers("request_validation", "Demande de validation TFJM²", team=team)
|
||||||
return redirect('tournament:team_detail', pk=team.pk)
|
return redirect('tournament:team_detail', pk=team.pk)
|
||||||
elif "validate" in request.POST and request.user.organizes:
|
elif "validate" in request.POST and request.user.organizes:
|
||||||
team.validation_status = "2valid"
|
team.validation_status = "2valid"
|
||||||
|
|
Loading…
Reference in New Issue