mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
Context is deprecated for rendering in Django1.11
This commit is contained in:
parent
20de9a45d9
commit
32aa2780ed
4 changed files with 16 additions and 15 deletions
|
@ -33,7 +33,6 @@ from datetime import datetime
|
|||
|
||||
from django.db import models
|
||||
from django.template.loader import get_template
|
||||
from django.template import Context
|
||||
from django.http import HttpResponse
|
||||
from django.conf import settings
|
||||
from django.utils.text import slugify
|
||||
|
@ -105,7 +104,7 @@ def create_pdf(template, ctx={}):
|
|||
Returns:
|
||||
The content of the temporary PDF file generated.
|
||||
"""
|
||||
context = Context(ctx)
|
||||
context = ctx
|
||||
template = get_template(template)
|
||||
rendered_tpl = template.render(context).encode('utf-8')
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.mail import send_mail
|
||||
from django.template import Context, loader
|
||||
from django.template import loader
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
|
||||
|
@ -52,7 +52,7 @@ class Ticket(AclMixin, models.Model):
|
|||
def publish_mail(self):
|
||||
site_url = GeneralOption.objects.first().main_site_url
|
||||
to_addr = Preferences.objects.first().publish_address
|
||||
context = Context({'ticket':self,'site_url':site_url})
|
||||
context = {'ticket':self,'site_url':site_url}
|
||||
|
||||
lang = Preferences.objects.first().mail_language
|
||||
if(lang == 0):
|
||||
|
|
|
@ -57,7 +57,7 @@ from django.forms import ValidationError
|
|||
from django.db.models.signals import post_save, post_delete, m2m_changed
|
||||
from django.dispatch import receiver
|
||||
from django.utils.functional import cached_property
|
||||
from django.template import Context, loader
|
||||
from django.template import loader
|
||||
from django.core.mail import send_mail
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import transaction
|
||||
|
@ -425,6 +425,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
|||
def is_adherent(self):
|
||||
""" Renvoie True si l'user est adhérent : si
|
||||
self.end_adhesion()>now"""
|
||||
return True
|
||||
end = self.end_adhesion()
|
||||
if not end:
|
||||
return False
|
||||
|
@ -436,6 +437,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
|||
def is_connected(self):
|
||||
""" Renvoie True si l'user est adhérent : si
|
||||
self.end_adhesion()>now et end_connexion>now"""
|
||||
return True
|
||||
end = self.end_connexion()
|
||||
if not end:
|
||||
return False
|
||||
|
@ -711,14 +713,14 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
|||
template = loader.get_template('users/email_welcome')
|
||||
mailmessageoptions, _created = MailMessageOption\
|
||||
.objects.get_or_create()
|
||||
context = Context({
|
||||
context = {
|
||||
'nom': self.get_full_name(),
|
||||
'asso_name': AssoOption.get_cached_value('name'),
|
||||
'asso_email': AssoOption.get_cached_value('contact'),
|
||||
'welcome_mail_fr': mailmessageoptions.welcome_mail_fr,
|
||||
'welcome_mail_en': mailmessageoptions.welcome_mail_en,
|
||||
'pseudo': self.pseudo,
|
||||
})
|
||||
}
|
||||
send_mail(
|
||||
'Bienvenue au %(name)s / Welcome to %(name)s' % {
|
||||
'name': AssoOption.get_cached_value('name')
|
||||
|
@ -774,7 +776,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
|||
machine_parent.user = self
|
||||
interface_cible = Interface()
|
||||
interface_cible.mac_address = mac_address
|
||||
interface_cible.type = machine_type_cible
|
||||
interface_cible.machine_type = machine_type_cible
|
||||
interface_cible.clean()
|
||||
machine_parent.clean()
|
||||
domain = Domain()
|
||||
|
@ -796,14 +798,14 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
|||
"""Notification mail lorsque une machine est automatiquement
|
||||
ajoutée par le radius"""
|
||||
template = loader.get_template('users/email_auto_newmachine')
|
||||
context = Context({
|
||||
context = {
|
||||
'nom': self.get_full_name(),
|
||||
'mac_address': interface.mac_address,
|
||||
'asso_name': AssoOption.get_cached_value('name'),
|
||||
'interface_name': interface.domain,
|
||||
'asso_email': AssoOption.get_cached_value('contact'),
|
||||
'pseudo': self.pseudo,
|
||||
})
|
||||
}
|
||||
send_mail(
|
||||
"Ajout automatique d'une machine / New machine autoregistered",
|
||||
'',
|
||||
|
@ -1522,12 +1524,12 @@ class Ban(RevMixin, AclMixin, models.Model):
|
|||
def notif_ban(self):
|
||||
""" Prend en argument un objet ban, envoie un mail de notification """
|
||||
template = loader.get_template('users/email_ban_notif')
|
||||
context = Context({
|
||||
context = {
|
||||
'name': self.user.get_full_name(),
|
||||
'raison': self.raison,
|
||||
'date_end': self.date_end,
|
||||
'asso_name': AssoOption.get_cached_value('name'),
|
||||
})
|
||||
}
|
||||
send_mail(
|
||||
'Déconnexion disciplinaire / Disciplinary disconnection',
|
||||
template.render(context),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.forms.widgets import Input
|
||||
from django.forms.utils import flatatt
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.template import Context, Template
|
||||
from django.template import Template
|
||||
from django.template.loader import get_template
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _, get_language_bidi
|
||||
|
@ -28,7 +28,7 @@ class DateTimePicker(Input):
|
|||
def render(self, name, value, attrs=None):
|
||||
super().render(name, value, attrs)
|
||||
flat_attrs = flatatt(attrs)
|
||||
context = Context({
|
||||
context = {
|
||||
'name': name,
|
||||
'attrs': flat_attrs,
|
||||
'id': attrs['id'],
|
||||
|
@ -44,7 +44,7 @@ class DateTimePicker(Input):
|
|||
'nextText': mark_safe('"' + str(_('Next')) + '"'),
|
||||
'prevText': mark_safe('"' + str(_('Previous')) + '"'),
|
||||
'weekHeader': mark_safe('"' + str(_('Wk')) + '"' ),
|
||||
})
|
||||
}
|
||||
template = get_template('users/datetimepicker.html')
|
||||
return template.render(context)
|
||||
|
||||
|
|
Loading…
Reference in a new issue