From 19f4fdbf97876e0b2514dc3124dccd33335c2ee8 Mon Sep 17 00:00:00 2001 From: Grizzly Date: Wed, 14 Aug 2019 15:09:46 +0000 Subject: [PATCH] Ajout d'un lien vers le profil dans le mail --- tickets/models.py | 10 ++++++++-- tickets/templates/tickets/publication_mail | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tickets/models.py b/tickets/models.py index ed446064..5ec2e544 100644 --- a/tickets/models.py +++ b/tickets/models.py @@ -11,6 +11,8 @@ from preferences.models import GeneralOption import users.models +from .preferences.models import Preferences + class Ticket(AclMixin, models.Model): """Class définissant un ticket""" @@ -49,12 +51,16 @@ class Ticket(AclMixin, models.Model): verbose_name_plural = _("Tickets") def __str__(self): - return "Ticket de {} date: {}".format(self.user.surname,self.date) + if self.user: + return "Ticket de {}. Date: {}".format(self.user.surname,self.date) + else: + return "Ticket anonyme. Date: {}".format(self.date) def publish_mail(self): + site_url = GeneralOption.objects.first().main_site_url to_addr = Preferences.objects.first().publish_address template = loader.get_template('tickets/publication_mail') - context = Context({'ticket':self}) + context = Context({'ticket':self,'site_url':site_url}) send_mail( 'Nouvelle ouverture de ticket', template.render(context), diff --git a/tickets/templates/tickets/publication_mail b/tickets/templates/tickets/publication_mail index f68c729d..1f3752be 100644 --- a/tickets/templates/tickets/publication_mail +++ b/tickets/templates/tickets/publication_mail @@ -1,5 +1,5 @@ -{% if ticket.user %} -{{ ticket.user.get_full_name }} à ouvert un ticket. +{% if ticket.user %} {{ ticket.user.get_full_name }} à ouvert un ticket. +Profile: {{site_url}}{% url 'users:profil' ticket.user.id%} Répondre à l'adresse: {{ticket.user.get_mail}}. {% else %}