From 42e4c24cc19c56b7d05af1cba13c0d465e641f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 26 Feb 2016 12:34:26 +0100 Subject: [PATCH] mail: display mail note in summary (#10096) --- welco/sources/mail/models.py | 4 ++++ .../mail/templates/welco/mail_summary.html | 15 +++++++++++++++ welco/sources/mail/views.py | 7 +++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/welco/sources/mail/models.py b/welco/sources/mail/models.py index 66d7164..0c7d731 100644 --- a/welco/sources/mail/models.py +++ b/welco/sources/mail/models.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import re import subprocess from django.contrib.contenttypes import generic @@ -82,6 +83,9 @@ class Mail(models.Model): user_details = get_wcs_data('api/users/%s/' % self.contact_id) return user_details.get('user_display_name') + def html_note(self): + return re.sub(r'[\r?\n]+', '

', self.note, re.DOTALL) + @receiver(post_save, sender=Mail) def create_thumbnail(sender, instance, created, **kwargs): diff --git a/welco/sources/mail/templates/welco/mail_summary.html b/welco/sources/mail/templates/welco/mail_summary.html index 5c7f5e8..0d008f1 100644 --- a/welco/sources/mail/templates/welco/mail_summary.html +++ b/welco/sources/mail/templates/welco/mail_summary.html @@ -5,6 +5,21 @@

+{% if object.note %} +

+{{object.html_note|safe}} +

+ +{% endif %} + {% if object.associations.all|length > 1 %} {% trans 'Mail with multiple formdata:' %}