This commit is contained in:
tonio
2010-05-05 13:18:12 +02:00
parent 7480e479e7
commit 6adbc5c6be
9 changed files with 64 additions and 25 deletions
+1
View File
@@ -45,6 +45,7 @@ class AliasForm(forms.ModelForm):
del kwargs["domain"]
super(AliasForm, self).__init__(*args, **kwargs)
self.fields['address'].widget.attrs['size'] = 14
self.fields['mbox'].widget.attrs['size'] = 5
if domain:
self.fields['mbox'].queryset = Mailbox.objects.filter(domain=domain.id)
+3 -3
View File
@@ -115,7 +115,7 @@ def index(request, message=None):
@login_required
def getmailcontent(request, mail_id):
from mailng.lib.email_listing import Email
from sql_listing import SQLemail
conn = db.getconnection("amavis_quarantine")
status, cursor = db.execute(conn, """
@@ -129,9 +129,9 @@ WHERE quarantine.mail_id='%s'
msg = email.message_from_string(content)
links = request.GET.has_key("links") and request.GET["links"] or "0"
mode = request.GET.has_key("mode") and request.GET["mode"] or "plain"
mail = Email(msg, mode, links)
mail = SQLemail(msg, mode, links)
return _render(request, "common/viewmail.html", {
"headers" : "",
"headers" : mail.render_headers(),
"mailbody" : mail.body,
"pre" : mail.pre
})
+19 -1
View File
@@ -3,7 +3,7 @@
from datetime import datetime
from django.utils.translation import ugettext as _
from mailng.lib import tables, db
from mailng.lib.email_listing import MBconnector, EmailListing
from mailng.lib.email_listing import MBconnector, EmailListing, Email
class Qtable(tables.Table):
tableid = "emails"
@@ -92,3 +92,21 @@ class SQLlisting(EmailListing):
def __init__(self, filter, **kwargs):
self.mbc = SQLconnector(filter)
EmailListing.__init__(self, **kwargs)
class SQLemail(Email):
def __init__(self, msg, *args, **kwargs):
Email.__init__(self, msg, *args, **kwargs)
fields = ["X-Amavis-Alert", "Subject", "From", "To", "Date"]
for f in fields:
label = f
if not msg.has_key(f):
f = f.upper()
if not msg.has_key(f):
self.headers += [{"name" : label, "value" : ""}]
continue
self.headers += [{"name" : label, "value" : msg[f]}]
try:
label = re.sub("-", "_", label)
setattr(self, label, msg[f])
except:
pass
+15 -2
View File
@@ -349,8 +349,8 @@ class ImapListing(EmailListing):
self.mbc.criterions = ["(%s)" % criterions]
class ImapEmail(Email):
def __init__(self, msg, addrfull=False, **kwargs):
Email.__init__(self, msg, **kwargs)
def __init__(self, msg, addrfull=False, *args, **kwargs):
Email.__init__(self, msg, *args, **kwargs)
fields = ["Subject", "From", "To", "Reply-To", "Cc", "Date"]
for f in fields:
@@ -371,3 +371,16 @@ class ImapEmail(Email):
except:
pass
def render_headers(self, **kwargs):
attachments = []
for part in self.attachments:
decoded = decode_header(part.get_filename())
if decoded[0][1] is None:
attachments += [decoded[0][0]]
else:
attachments += [unicode(decoded[0][0], decoded[0][1])]
return render_to_string("webmail/headers.html", {
"headers" : self.headers,
"folder" : kwargs["folder"], "mail_id" : kwargs["mail_id"],
"attachments" : attachments != [] and attachments or None
})
+6 -7
View File
@@ -1,9 +1,8 @@
{% extends "common/mailheaders.html" %}
{% load i18n %}
<table id="emailheaders">
{% for hdr in headers %}
<tr><th width="130px">{{ hdr.name }}</th><td>{{ hdr.value }}</td></tr>
{% endfor %}
{% if attachments %}
{% block extraheaders %}
{% if attachments %}
<tr>
<th>{% trans "Attachments" %}</th>
<td>
@@ -13,5 +12,5 @@
{% endfor %}
</td>
</tr>
{% endif %}
</table>
{% endif %}
{% endblock %}
+2 -11
View File
@@ -187,18 +187,9 @@ class Email(object):
return map[m.group(1)]
return url
def render_headers(self, folder, mail_id):
attachments = []
for part in self.attachments:
decoded = decode_header(part.get_filename())
if decoded[0][1] is None:
attachments += [decoded[0][0]]
else:
attachments += [unicode(decoded[0][0], decoded[0][1])]
return render_to_string("webmail/headers.html", {
def render_headers(self, **kwargs):
return render_to_string("common/mailheaders.html", {
"headers" : self.headers,
"folder" : folder, "mail_id" : mail_id,
"attachments" : attachments != [] and attachments or None
})
def render(self, request):
+10
View File
@@ -26,11 +26,21 @@ input {
padding: 2px;
}
input[type=text] {
width: 130px
}
input:hover {
color: inherit;
background-color: #ffffcc;
}
select {
width: 135px;
background-color: #eee;
border: 1px solid #cccccc;
}
td.odd {
background: #F7F9Fb;
}
+1 -1
View File
@@ -32,7 +32,7 @@
</a>
{% url admin.views.newalias domain.id mb.id as alias_url %}
<a href="{{ alias_url }}" class="boxed"
rel="{handler:'iframe',size:{x:300,y:190}}">
rel="{handler:'iframe',size:{x:300,y:250}}">
<img src="/static/pics/add.png" border="0" title="{% trans 'Add new alias' %}"/>
</a>
{% url mbox-aliases domain.id mb.id as aliases_url %}
+7
View File
@@ -0,0 +1,7 @@
{% load i18n %}
<table id="emailheaders">
{% for hdr in headers %}
<tr><th width="130px">{{ hdr.name }}</th><td>{{ hdr.value }}</td></tr>
{% endfor %}
{% block extraheaders %}{% endblock %}
</table>