Supprime render_template

GestioCOF définit une fonction `render_template` qui permet de calculer
l'interpolation d'un gabarit en une chaîne de caractères, par exemple
pour l'envoi de mails. Ce patch supprime cette fonction et remplace son
utilisation par la fonction `django.template.loader.render_to_string` au
comportement identique.
This commit is contained in:
Basile Clement 2016-11-08 07:34:19 +01:00 committed by Basile Clement
parent a55d34380c
commit 1f1419c5f1
3 changed files with 29 additions and 36 deletions

View file

@ -11,19 +11,13 @@ from datetime import timedelta
from django.contrib.sites.models import Site
from django.db import models
from django.contrib.auth.models import User
from django.template import loader, Context
from django.template import loader
from django.core import mail
from django.conf import settings
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
def render_template(template_name, data):
tmpl = loader.get_template(template_name)
ctxt = Context(data)
return tmpl.render(ctxt)
@python_2_unicode_compatible
class Tirage(models.Model):
title = models.CharField("Titre", max_length=300)
@ -117,7 +111,7 @@ class Spectacle(models.Model):
mail_object = "%s - %s - %s" % (self.title, self.date_no_seconds(),
self.location)
for member in members.values():
mail_body = render_template('mail-rappel.txt', {
mail_body = loader.render_to_string('mail-rappel.txt', {
'name': member[0],
'nb_attr': member[1],
'show': self})
@ -277,7 +271,7 @@ class SpectacleRevente(models.Model):
mails_to_send = []
mail_object = "%s" % (self.attribution.spectacle)
for participant in inscrits:
mail_body = render_template('mail-revente.txt', {
mail_body = loader.render_to_string('mail-revente.txt', {
'user': participant.user,
'spectacle': self.attribution.spectacle,
'revente': self,
@ -301,7 +295,7 @@ class SpectacleRevente(models.Model):
mails_to_send = []
mail_object = "%s" % (self.attribution.spectacle)
for participant in inscrits:
mail_body = render_template('mail-shotgun.txt', {
mail_body = loader.render_to_string('mail-shotgun.txt', {
'user': participant.user,
'spectacle': self.attribution.spectacle,
'domain': Site.objects.get_current(),
@ -337,13 +331,15 @@ class SpectacleRevente(models.Model):
'spectacle': spectacle,
}
mails.append(mail.EmailMessage(
mail_subject, loader.render_to_string('mail-revente-winner.txt', context),
mail_subject,
loader.render_to_string('mail-revente-winner.txt', context),
from_email=settings.MAIL_DATA['revente']['FROM'],
to=[winner.user.email],
reply_to=[seller.user.email],
))
mails.append(mail.EmailMessage(
mail_subject, loader.render_to_string('mail-revente-seller.txt', context),
mail_subject,
loader.render_to_string('mail-revente-seller.txt', context),
from_email=settings.MAIL_DATA['revente']['FROM'],
to=[seller.user.email],
reply_to=[winner.user.email],