mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-25 05:58:42 +01:00
Big webmail update:
* Dragging multiple messages is now possible * Better email displaying (headers and body are now displayed at the same time...) * Bugfixes about dropdown menus * Misc. enhancements.
This commit is contained in:
+13
-1
@@ -3,6 +3,7 @@ import time
|
||||
import re
|
||||
import lxml
|
||||
import lxml.html
|
||||
from lxml import etree
|
||||
from django.template.loader import render_to_string
|
||||
from django.template import Template, Context
|
||||
from mailng.lib import _render, decode
|
||||
@@ -124,6 +125,7 @@ class Email(object):
|
||||
def __init__(self, msg, mode="plain", links="0"):
|
||||
self.attached_map = {}
|
||||
contents = {"html" : "", "plain" : ""}
|
||||
self.headers = []
|
||||
for part in msg.walk():
|
||||
if part.get_content_maintype() == 'multipart':
|
||||
continue
|
||||
@@ -166,6 +168,11 @@ class Email(object):
|
||||
return map[m.group(1)]
|
||||
return url
|
||||
|
||||
def render_headers(self):
|
||||
return render_to_string("webmail/headers.html", {
|
||||
"headers" : self.headers
|
||||
})
|
||||
|
||||
def render(self, request):
|
||||
return _render(request, 'common/getmailcontent.html', {
|
||||
"body" : self.body, "pre" : self.pre
|
||||
@@ -182,6 +189,11 @@ class Email(object):
|
||||
html.rewrite_links(lambda x: None)
|
||||
else:
|
||||
html.rewrite_links(self.map_cid)
|
||||
body = lxml.html.tostring(html)
|
||||
body = html.find("body")
|
||||
if not body:
|
||||
body = lxml.html.tostring(html)
|
||||
else:
|
||||
body = lxml.html.tostring(body)
|
||||
body = re.sub("<(/?)body", lambda m: "<%sdiv" % m.group(1), body)
|
||||
body = Template(decode(body)).render({})
|
||||
return (False, body)
|
||||
|
||||
+8
-1
@@ -5,6 +5,8 @@ from django.template import Template, Context
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
class Column:
|
||||
sortable = True
|
||||
|
||||
def __init__(self, name, **kwargs):
|
||||
self.name = name
|
||||
for k, v in kwargs.iteritems():
|
||||
@@ -26,8 +28,13 @@ class SelectionColumn(Column):
|
||||
% (self.name, value)
|
||||
|
||||
class ImgColumn(Column):
|
||||
sortable = False
|
||||
|
||||
def __str__(self):
|
||||
return ""
|
||||
try:
|
||||
return getattr(self, "header")
|
||||
except AttributeError:
|
||||
return ""
|
||||
|
||||
def render(self, value):
|
||||
return "<img src='%s' />" % value
|
||||
|
||||
Reference in New Issue
Block a user