summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2016-02-26 11:34:26 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2016-02-26 11:34:26 (GMT)
commit42e4c24cc19c56b7d05af1cba13c0d465e641f3c (patch)
tree78f5c2b0982b3da618a73c9195f82d302c082b95
parent1b21e15d071c0b872a2605109f81e809d3652b13 (diff)
downloadwelco-0.22.zip
welco-0.22.tar.gz
welco-0.22.tar.bz2
mail: display mail note in summary (#10096)v0.22
-rw-r--r--welco/sources/mail/models.py4
-rw-r--r--welco/sources/mail/templates/welco/mail_summary.html15
-rw-r--r--welco/sources/mail/views.py7
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 <http://www.gnu.org/licenses/>.
+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]+', '<br><br>', 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 @@
</a>
</p>
+{% if object.note %}
+<p class="postit">
+{{object.html_note|safe}}
+</p>
+<style>
+p.postit {
+ background: rgba(241,231,103,1);
+ transform: rotate(2deg);
+ box-shadow: 3px 3px 3px #aaa;
+ padding: 1ex;
+ width: 90%;
+}
+</style>
+{% endif %}
+
{% if object.associations.all|length > 1 %}
<strong>{% trans 'Mail with multiple formdata:' %}</strong>
<ul>
diff --git a/welco/sources/mail/views.py b/welco/sources/mail/views.py
index c4cb14f..1c1cff5 100644
--- a/welco/sources/mail/views.py
+++ b/welco/sources/mail/views.py
@@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
-import re
from django import template
from django.contrib.auth.decorators import login_required
@@ -111,9 +110,9 @@ edit_note = login_required(csrf_exempt(EditNote.as_view()))
@login_required
def note(request, *args, **kwargs):
mail = Mail.objects.get(id=kwargs['pk'])
- note = mail.note or '+'
- note = re.sub(r'[\r?\n]+', '<br><br>', note, re.DOTALL)
- return HttpResponse(note)
+ if not mail.note:
+ mail.note = '+'
+ return HttpResponse(mail.html_note())
@login_required