mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-25 05:58:42 +01:00
wip: Global user interface improvment
* The quarantine manager is done * The webmail is not yet completed * Cleanup * More...
This commit is contained in:
@@ -76,14 +76,15 @@ class SQLconnector(MBconnector):
|
||||
return emails
|
||||
|
||||
class SQLlisting(EmailListing):
|
||||
tpl = "amavis_quarantine/index.html"
|
||||
tpl = "amavis_quarantine/index2.html"
|
||||
tbltype = Qtable
|
||||
deflocation = "listing/"
|
||||
defcallback = "updatelisting"
|
||||
reset_wm_url = True
|
||||
table_styles = "table-condensed"
|
||||
|
||||
def __init__(self, user, msgs, filter, **kwargs):
|
||||
if user.belongs_to_group('SimpleUsers'):
|
||||
if user.group == 'SimpleUsers':
|
||||
Qtable.cols_order = ['type', 'rstatus', 'from_', 'subject', 'time']
|
||||
else:
|
||||
Qtable.cols_order = ['type', 'rstatus', 'to', 'from_', 'subject', 'time']
|
||||
|
||||
@@ -1,8 +1,29 @@
|
||||
#menubar {
|
||||
position: fixed;
|
||||
top: 60px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
#listing {
|
||||
position: fixed;
|
||||
padding: 0 15px;
|
||||
right: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#mailcontent {
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
thead tr {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
tr.table-tr-selected {
|
||||
background: #ffffcc;
|
||||
}
|
||||
td.unseen {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@@ -1,136 +1,180 @@
|
||||
function updatehash(evt) {
|
||||
evt.stop();
|
||||
var url = $defined(this.get("href")) ? this.get("href") : "";
|
||||
current_anchor.parse_string(url, true).setparams(navparams);
|
||||
current_anchor.update();
|
||||
}
|
||||
var Quarantine = function(options) {
|
||||
this.initialize(options);
|
||||
};
|
||||
|
||||
function appendhash(evt) {
|
||||
evt.stop();
|
||||
location.hash += evt.target.get("href");
|
||||
}
|
||||
Quarantine.prototype = {
|
||||
constructor: Quarantine,
|
||||
|
||||
function updateparams(evt) {
|
||||
evt.stop();
|
||||
current_anchor.updateparams(evt.target.get("href"));
|
||||
current_anchor.update();
|
||||
}
|
||||
defaults: {
|
||||
deflocation: "listing",
|
||||
defcallback: "listing_cb"
|
||||
},
|
||||
|
||||
function actioncallback(resp) {
|
||||
$("listing").set("html", "");
|
||||
$("menubar").set("html", "");
|
||||
$("navbar").set("html", "");
|
||||
if (resp.status == "ok") {
|
||||
infobox.info(resp.respmsg);
|
||||
current_anchor.parse_string(resp.url, true).setparams(navparams);
|
||||
current_anchor.update(1);
|
||||
} else {
|
||||
infobox.error(resp.respmsg);
|
||||
}
|
||||
}
|
||||
initialize: function(options) {
|
||||
this.options = $.extend({}, this.defaults, options);
|
||||
this.navobj = new History(this.options);
|
||||
|
||||
function actionclick(evt) {
|
||||
new Request.JSON.mdb({
|
||||
url: evt.target.get("href"),
|
||||
onSuccess: actioncallback
|
||||
}).get();
|
||||
}
|
||||
this.register_navcallbacks();
|
||||
this.listen();
|
||||
},
|
||||
|
||||
function deleteclick(evt) {
|
||||
evt.stop();
|
||||
if (!confirm(gettext("Delete this message?"))) {
|
||||
return false;
|
||||
update_page: function(data) {
|
||||
if (data.menu != undefined) {
|
||||
$("#menubar").html(data.menu);
|
||||
$("#searchfield").searchbar({navobj: this.navobj});
|
||||
}
|
||||
if (data.navbar) {
|
||||
$("#bottom-bar-in").html(data.navbar);
|
||||
}
|
||||
if (data.listing != undefined) {
|
||||
$("#listing").html(data.listing);
|
||||
$("#listing").css({
|
||||
top: $("#menubar").outerHeight() + 60 + "px",
|
||||
bottom: $("#bottom-bar").outerHeight() + "px",
|
||||
overflow: "auto"
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
listen: function() {
|
||||
$(document).on("dblclick", "tbody>tr", $.proxy(this.viewmail_loader, this));
|
||||
$(document).on("click", "a[name=selectmsgs]", $.proxy(this.selectmsgs, this));
|
||||
$(document).on("click", "a[name=release-multi]",
|
||||
$.proxy(this.release_selection, this));
|
||||
$(document).on("click", "a[name=delete-multi]",
|
||||
$.proxy(this.delete_selection, this));
|
||||
$(document).on("click", "#bottom-bar a", $.proxy(this.load_page, this));
|
||||
|
||||
$(document).on("click", "a[name=release]", $.proxy(this.release, this));
|
||||
$(document).on("click", "a[name=delete]", $.proxy(this.delete, this));
|
||||
$(document).on("click", "a[name=viewmode]", $.proxy(this.update_params, this));
|
||||
},
|
||||
|
||||
load_page: function(e) {
|
||||
e.preventDefault();
|
||||
var $link = $(e.target).parent();
|
||||
|
||||
this.navobj.deleteParam("rcpt");
|
||||
this.navobj.from_string($link.attr("href")).update();
|
||||
},
|
||||
|
||||
viewmail_loader: function(e) {
|
||||
e.preventDefault();
|
||||
var $tr = $(e.target).parent();
|
||||
var $to = $tr.find("td[name=to]");
|
||||
|
||||
this.navobj.baseurl($tr.attr("id"));
|
||||
if ($to.length) {
|
||||
this.navobj.setparam("rcpt", $to.html().trim());
|
||||
}
|
||||
this.navobj.update();
|
||||
},
|
||||
|
||||
selectmsgs: function(e) {
|
||||
e.preventDefault();
|
||||
var type = $(e.target).attr("href");
|
||||
|
||||
if (type == "") {
|
||||
$("#emails").htmltable("clear_selection");
|
||||
return;
|
||||
}
|
||||
$("td[name=type]").each(function() {
|
||||
var $this = $(this);
|
||||
if ($this.html().trim() == type) {
|
||||
$("#emails").htmltable("select_row", $this.parent());
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_send_selection: function(e, name, message) {
|
||||
var $link = $(e.target);
|
||||
|
||||
e.preventDefault();
|
||||
if (!this.htmltable.current_selection().length ||
|
||||
!confirm(message)) {
|
||||
return;
|
||||
}
|
||||
var selection = [];
|
||||
|
||||
this.htmltable.current_selection().each(function() {
|
||||
var $tr = $(this);
|
||||
var $to = $tr.find("td[name=to]");
|
||||
|
||||
if ($to.length) {
|
||||
selection.push($to.html().trim() + " " + $tr.attr("id"));
|
||||
} else {
|
||||
selection.push($tr.attr("id"));
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: $link.attr("href"),
|
||||
data: "action=" + name + "&selection=" + selection.join(","),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
success: $.proxy(this.action_cb, this)
|
||||
});
|
||||
},
|
||||
|
||||
release_selection: function(e) {
|
||||
this._send_selection(e, "release", gettext("Release this selection?"));
|
||||
},
|
||||
|
||||
delete_selection: function(e) {
|
||||
this._send_selection(e, "delete", gettext("Delete this selection?"));
|
||||
},
|
||||
|
||||
_send_action: function(e, message) {
|
||||
var $link = $(e.target);
|
||||
|
||||
e.preventDefault();
|
||||
if (!confirm(message)) {
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: $link.attr("href"),
|
||||
dataType: 'json',
|
||||
success: $.proxy(this.action_cb, this)
|
||||
});
|
||||
},
|
||||
|
||||
release: function(e) {
|
||||
this._send_action(e, gettext("Release this message?"));
|
||||
},
|
||||
|
||||
delete: function(e) {
|
||||
this._send_action(e, gettext("Delete this message?"));
|
||||
},
|
||||
|
||||
update_params: function(e) {
|
||||
var $link = $(e.target);
|
||||
e.preventDefault();
|
||||
this.navobj.updateparams($link.attr("href")).update();
|
||||
},
|
||||
|
||||
register_navcallbacks: function() {
|
||||
this.navobj.register_callback("_listing",
|
||||
$.proxy(this.listing_cb, this));
|
||||
this.navobj.register_callback("viewmail",
|
||||
$.proxy(this.viewmail_cb, this));
|
||||
},
|
||||
|
||||
listing_cb: function(data) {
|
||||
this.update_page(data);
|
||||
$("#emails").htmltable();
|
||||
this.htmltable = $("#emails").data("htmltable");
|
||||
},
|
||||
|
||||
viewmail_cb: function(data) {
|
||||
this.update_page(data);
|
||||
$("#listing").css("overflow", "hidden");
|
||||
},
|
||||
|
||||
action_cb: function(data) {
|
||||
if (data.status == "ok") {
|
||||
this.navobj.parse_string(data.url, true).update(true);
|
||||
$("body").notify("success", data.respmsg, 2000);
|
||||
} else {
|
||||
$("body").notify("error", data.respmsg);
|
||||
}
|
||||
}
|
||||
actionclick(evt);
|
||||
}
|
||||
|
||||
function releaseclick(evt) {
|
||||
evt.stop();
|
||||
if (!confirm(gettext("Release this message?"))) {
|
||||
return false;
|
||||
}
|
||||
actionclick(evt);
|
||||
}
|
||||
|
||||
function viewmail_cs(evt) {
|
||||
evt.stop();
|
||||
var to = this.getFirst("td[name=to]");
|
||||
|
||||
current_anchor.baseurl(this.get("id"));
|
||||
if ($defined(to)) {
|
||||
current_anchor.setparam("rcpt", to.get("html").trim());
|
||||
}
|
||||
current_anchor.update();
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback of the 'listing' action (the main screen)
|
||||
*/
|
||||
function listing_cb(resp) {
|
||||
updatelisting(resp);
|
||||
|
||||
var tbl = new HtmlTable($("emails"), {
|
||||
useKeyboard: false,
|
||||
selectable: true
|
||||
});
|
||||
|
||||
if ($("toggleselect")) {
|
||||
$("toggleselect").addEvent("click", function(evt) {
|
||||
if ($$("tr[class*=table-tr-selected]").length) {
|
||||
tbl.selectNone();
|
||||
} else {
|
||||
tbl.selectAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
$$("a[name=selectmsgs]").addEvent("click", function(evt) {
|
||||
evt.stop();
|
||||
var type = evt.target.get("href");
|
||||
|
||||
if (!$chk(type)) {
|
||||
$$("tr[class*=table-tr-selected]").each(function(item) {
|
||||
item.removeClass("table-tr-selected");
|
||||
});
|
||||
if ($("toggleselect").checked) {
|
||||
$("toggleselect").checked = false;
|
||||
tbl.selectNone();
|
||||
}
|
||||
return;
|
||||
}
|
||||
$$("td[name=type]").each(function(item) {
|
||||
if (item.get("html").trim() == type) {
|
||||
item.getParent().addClass("table-tr-selected");
|
||||
}
|
||||
});
|
||||
});
|
||||
$$("a[name=release]").addEvent("click", function(event) {
|
||||
if (!checkTableSelection(gettext("Release this selection?"))) {
|
||||
event.stop();
|
||||
return;
|
||||
}
|
||||
mysubmit(event, "release");
|
||||
});
|
||||
$$("a[name=delete]").addEvent("click", function(event) {
|
||||
if (!checkTableSelection(gettext("Delete this selection?"))) {
|
||||
event.stop();
|
||||
return;
|
||||
}
|
||||
mysubmit(event, "delete");
|
||||
});
|
||||
searchbox_init();
|
||||
init_sortable_columns();
|
||||
update_sortable_column();
|
||||
$$("tbody>tr").addEvent("dblclick", viewmail_cs);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback of the 'viewmail' action
|
||||
*/
|
||||
function viewmail_cb(resp) {
|
||||
updatelisting(resp);
|
||||
$$("a[name=back]").addEvent("click", updatehash);
|
||||
$$("a[name=delete]").addEvent("click", deleteclick);
|
||||
$$("a[name=release]").addEvent("click", releaseclick);
|
||||
$$("a[name=viewmode]").addEvent("click", updateparams);
|
||||
setDivHeight("mailcontent", 5, 0);
|
||||
}
|
||||
};
|
||||
@@ -1,42 +1,22 @@
|
||||
{% extends "common/email_listing.html" %}
|
||||
{% load i18n %}
|
||||
{% extends "fixed.html" %}
|
||||
{% block html_head %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}amavis_quarantine/css/quarantine.css" />
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.htmltable.js"></script>
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}js/history.js"></script>
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}js/searchbar.js"></script>
|
||||
<script type="text/javascript" src="{{ MEDIA_URL }}amavis_quarantine/js/quarantine.js"></script>
|
||||
{{ block.super }}
|
||||
<script type="text/javascript">
|
||||
mysubmit = function(event, name) {
|
||||
event.stop();
|
||||
var selection = new Array();
|
||||
$$("tr[class*=table-tr-selected]").each(function(item) {
|
||||
var content = "";
|
||||
var to = item.getFirst("td[name=to]");
|
||||
|
||||
if ($defined(to)) {
|
||||
content = to.get("html").trim() + " ";
|
||||
}
|
||||
selection.push(content + item.get("id"));
|
||||
$(document).ready(function() {
|
||||
var qm = new Quarantine({
|
||||
deflocation: "{{ deflocation }}",
|
||||
defcallback: "{{ defcallback }}"
|
||||
});
|
||||
new Element("input", {
|
||||
"type" : "hidden", "name" : "selection", "value" : selection
|
||||
}).inject($("listingform"), "top");
|
||||
new Element('input', {
|
||||
'type' : 'hidden', 'name' : "action", style: "display:none", 'value' : name
|
||||
}).inject($("listingform"), "top");
|
||||
{% url modoboa.extensions.amavis_quarantine.views.process as actionurl %}
|
||||
$("listingform").set("action", "{{ actionurl }}");
|
||||
$("listingform").set("send", {
|
||||
onSuccess : function(res) {
|
||||
response = JSON.decode(res);
|
||||
actioncallback(response);
|
||||
}
|
||||
});
|
||||
$("listingform").send();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block js %}
|
||||
current_anchor.register_callback("_listing", listing_cb);
|
||||
current_anchor.register_callback("viewmail", viewmail_cb);
|
||||
{% block fixed_content %}
|
||||
<div id="menubar"></div>
|
||||
<div id="listing"></div>
|
||||
{% endblock %}
|
||||
{% block footer %}
|
||||
{% endblock %}
|
||||
{% block middletitle %}{% trans "Quarantine" %}{% endblock %}
|
||||
|
||||
@@ -1,43 +1,11 @@
|
||||
{% extends "layout_simple.html" %}
|
||||
{% extends "common/generic_modal.html" %}
|
||||
{% load i18n %}
|
||||
{% block html_head %}
|
||||
<style type="text/css">
|
||||
table {
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 20px;
|
||||
}
|
||||
|
||||
table th {
|
||||
background: #CEDBEC;
|
||||
text-align: left;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
table td {
|
||||
border-bottom: 1px solid #C8D6E8;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
td.odd {
|
||||
background: #F7F9Fb;
|
||||
}
|
||||
|
||||
td {
|
||||
font-size: smaller;
|
||||
height: 40px;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<table border="0">
|
||||
<tr><th colspan="2">{% trans "Message headers" %}</th></tr>
|
||||
{% block modalbody %}
|
||||
<table class="table table-condensed table-striped">
|
||||
{% for k, v in headers %}
|
||||
<tr>
|
||||
<td class="odd">{{ k }}</td><td>{{ v }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -24,46 +24,44 @@ def viewm_menu(selection, backurl, mail_id, rcpt, perms):
|
||||
|
||||
entries = [
|
||||
{"name" : "back",
|
||||
"url" : backurl,
|
||||
"img" : static_url("pics/back.png"),
|
||||
"img" : "icon-arrow-left",
|
||||
"url" : "javascript:history.go(-1);",
|
||||
"label" : _("Back to list")},
|
||||
{"name" : "headers",
|
||||
"url" : reverse(amavis_quarantine.views.viewheaders, args=[mail_id]),
|
||||
"img" : static_url("pics/add.png"),
|
||||
"label" : _("View full headers"),
|
||||
"class" : "boxed",
|
||||
"rel" : "{handler:'iframe',size:{x:600,y:500}}"},
|
||||
"modal" : True,
|
||||
"autowidth" : True},
|
||||
{"name" : "release",
|
||||
"img" : "icon-ok",
|
||||
"url" : reverse(amavis_quarantine.views.release, args=[mail_id]) \
|
||||
+ "?rcpt=%s" % rcpt,
|
||||
"img" : static_url("pics/release.png"),
|
||||
"label" : _("Release")},
|
||||
{"name" : "delete",
|
||||
"img" : "icon-remove",
|
||||
"url" : reverse(amavis_quarantine.views.delete, args=[mail_id]) \
|
||||
+ "?rcpt=%s" % rcpt,
|
||||
"img" : static_url("pics/remove.png"),
|
||||
"label" : _("Delete")},
|
||||
{"name" : "options",
|
||||
"label" : _("Options"),
|
||||
"img" : static_url("pics/settings.png"),
|
||||
"class" : "menubardropdown",
|
||||
"img" : "icon-cog",
|
||||
"menu" : options_menu}
|
||||
]
|
||||
|
||||
return render_to_string('common/menu.html',
|
||||
return render_to_string('common/buttons_list.html',
|
||||
{"selection" : selection, "entries" : entries,
|
||||
"perms" : perms})
|
||||
|
||||
@register.simple_tag
|
||||
def quar_menu(selection, user):
|
||||
entries = [
|
||||
{"name" : "release",
|
||||
"url" : "",
|
||||
"img" : static_url("pics/release.png"),
|
||||
{"name" : "release-multi",
|
||||
"url" : reverse(amavis_quarantine.views.process),
|
||||
"img" : "icon-ok",
|
||||
"label" : _("Release")},
|
||||
{"name" : "delete",
|
||||
"url" : "",
|
||||
"img" : static_url("pics/remove.png"),
|
||||
{"name" : "delete-multi",
|
||||
"img" : "icon-remove",
|
||||
"url" : reverse(amavis_quarantine.views.process),
|
||||
"label" : _("Delete")},
|
||||
{"name" : "select",
|
||||
"url" : "",
|
||||
@@ -87,9 +85,7 @@ def quar_menu(selection, user):
|
||||
}
|
||||
]
|
||||
|
||||
menu = render_to_string('common/menu.html',
|
||||
{"selection" : selection, "entries" : entries})
|
||||
if not user.belongs_to_group('SimpleUsers'):
|
||||
if user.group != 'SimpleUsers':
|
||||
extraopts = [{"name" : "to", "label" : _("To")}]
|
||||
else:
|
||||
extraopts = []
|
||||
@@ -97,4 +93,7 @@ def quar_menu(selection, user):
|
||||
"MEDIA_URL" : settings.MEDIA_URL,
|
||||
"extraopts" : extraopts
|
||||
})
|
||||
return menu + searchbar
|
||||
|
||||
return render_to_string('common/buttons_list.html', dict(
|
||||
selection=selection, entries=entries, extracontent=searchbar
|
||||
))
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# coding: utf-8
|
||||
import email
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.template import Template, Context
|
||||
@@ -29,14 +28,14 @@ def __get_current_url(request):
|
||||
return res
|
||||
|
||||
def empty_quarantine(request):
|
||||
content = "<div class='info'>%s</div>" % _("Empty quarantine")
|
||||
content = "<div class='alert alert-info'>%s</div>" % _("Empty quarantine")
|
||||
ctx = getctx("ok", level=2, listing=content, navbar="",
|
||||
menu=quar_menu("", request.user))
|
||||
return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
|
||||
|
||||
@login_required
|
||||
def _listing(request):
|
||||
filter = None
|
||||
flt = None
|
||||
rcptfilter = None
|
||||
msgs = None
|
||||
|
||||
@@ -60,11 +59,11 @@ def _listing(request):
|
||||
continue
|
||||
else:
|
||||
raise Exception("unsupported search criteria %s" % c)
|
||||
filter = nfilter if filter is None else filter | nfilter
|
||||
flt = nfilter if flt is None else flt | nfilter
|
||||
|
||||
q = ~Q(rs='D')
|
||||
if not request.user.is_superuser:
|
||||
if not request.user.belongs_to_group('SimpleUsers'):
|
||||
if request.user.group != 'SimpleUsers':
|
||||
doms = request.user.get_domains()
|
||||
if not len(doms):
|
||||
return empty_quarantine(request)
|
||||
@@ -73,7 +72,7 @@ def _listing(request):
|
||||
else:
|
||||
q &= Q(rid__email=request.user.email)
|
||||
|
||||
if not request.user.belongs_to_group('SimpleUsers') \
|
||||
if request.user.group != 'SimpleUsers' \
|
||||
and rcptfilter is not None:
|
||||
q &= Q(rid__email__contains=rcptfilter)
|
||||
msgs = Msgrcpt.objects.filter(q).values("mail_id")
|
||||
@@ -86,7 +85,7 @@ def _listing(request):
|
||||
del request.session["page"]
|
||||
pageid = 1
|
||||
|
||||
lst = SQLlisting(request.user, msgs, filter, baseurl="listing/",
|
||||
lst = SQLlisting(request.user, msgs, flt,
|
||||
navparams=request.session["navparams"],
|
||||
elems_per_page=int(parameters.get_user(request.user,
|
||||
"MESSAGES_PER_PAGE")))
|
||||
@@ -95,14 +94,16 @@ def _listing(request):
|
||||
return empty_quarantine(request)
|
||||
|
||||
content = lst.fetch(request, page.id_start, page.id_stop)
|
||||
navbar = lst.render_navbar(page)
|
||||
navbar = lst.render_navbar(page, "listing/")
|
||||
ctx = getctx("ok", listing=content, navbar=navbar,
|
||||
menu=quar_menu("", request.user))
|
||||
return HttpResponse(simplejson.dumps(ctx), mimetype="application/json")
|
||||
|
||||
@login_required
|
||||
def index(request):
|
||||
return SQLlisting(request.user, None, None, empty=True).render(request)
|
||||
return _render(request, "amavis_quarantine/index.html", dict(
|
||||
deflocation="listing/", defcallback="listing_cb", selection="quarantine"
|
||||
))
|
||||
|
||||
@login_required
|
||||
def getmailcontent(request, mail_id):
|
||||
@@ -123,7 +124,7 @@ def getmailcontent(request, mail_id):
|
||||
|
||||
@login_required
|
||||
def viewmail(request, mail_id):
|
||||
if not request.user.belongs_to_group('SimpleUsers'):
|
||||
if request.user.group != 'SimpleUsers':
|
||||
rcpt = request.GET["rcpt"]
|
||||
else:
|
||||
mb = Mailbox.objects.get(user=request.user)
|
||||
@@ -137,7 +138,7 @@ def viewmail(request, mail_id):
|
||||
args += ["%s=%s" % (kw, request.GET[kw])]
|
||||
|
||||
content = Template("""
|
||||
<iframe width="100%" frameBorder="0" src="{{ url }}" id="mailcontent"></iframe>
|
||||
<iframe src="{{ url }}" id="mailcontent"></iframe>
|
||||
""").render(Context({"url" : reverse(getmailcontent, args=[mail_id]) \
|
||||
+ "?%s" % "&".join(args)}))
|
||||
menu = viewm_menu("", __get_current_url(request), mail_id, rcpt,
|
||||
@@ -152,6 +153,7 @@ def viewheaders(request, mail_id):
|
||||
content += qm.mail_text
|
||||
msg = email.message_from_string(content)
|
||||
return _render(request, 'amavis_quarantine/viewheader.html', {
|
||||
"title" : _("Message headers"),
|
||||
"headers" : msg.items()
|
||||
})
|
||||
|
||||
@@ -166,7 +168,7 @@ def check_mail_id(request, mail_id):
|
||||
@login_required
|
||||
def delete(request, mail_id):
|
||||
mail_id = check_mail_id(request, mail_id)
|
||||
if request.user.belongs_to_group('SimpleUsers'):
|
||||
if request.user.group == 'SimpleUsers':
|
||||
mb = Mailbox.objects.get(user=request.user)
|
||||
msgrcpts = Msgrcpt.objects.filter(mail__in=mail_id, rid__email=mb.full_address)
|
||||
msgrcpts.update(rs='D')
|
||||
@@ -186,7 +188,7 @@ def delete(request, mail_id):
|
||||
@login_required
|
||||
def release(request, mail_id):
|
||||
mail_id = check_mail_id(request, mail_id)
|
||||
if request.user.belongs_to_group('SimpleUsers'):
|
||||
if request.user.group == 'SimpleUsers':
|
||||
mb = Mailbox.objects.get(user=request.user)
|
||||
msgrcpts = Msgrcpt.objects.filter(mail__in=mail_id, rid__email=mb.full_address)
|
||||
else:
|
||||
|
||||
@@ -367,13 +367,13 @@ class IMAPconnector(object):
|
||||
if len(topmailbox):
|
||||
md_mailboxes = []
|
||||
else:
|
||||
md_mailboxes = [{"name" : "INBOX", "class" : "inbox"},
|
||||
md_mailboxes = [{"name" : "INBOX", "class" : "icon-home"},
|
||||
{"name" : parameters.get_user(user, "DRAFTS_FOLDER"),
|
||||
"class" : "drafts"},
|
||||
"class" : "icon-file"},
|
||||
{"name" : 'Junk'},
|
||||
{"name" : parameters.get_user(user, "SENT_FOLDER")},
|
||||
{"name" : parameters.get_user(user, "TRASH_FOLDER"),
|
||||
"class" : "trash"}]
|
||||
"class" : "icon-trash"}]
|
||||
md_mailboxes += self._listfolders(topmailbox, md_mailboxes)
|
||||
if unseen_messages:
|
||||
for fd in md_mailboxes:
|
||||
@@ -476,7 +476,10 @@ class IMAPconnector(object):
|
||||
return
|
||||
|
||||
data = self._cmd("GETQUOTAROOT", self._encodefolder(mailbox))
|
||||
print data
|
||||
if data is None:
|
||||
self.quota_limit = self.quota_actual = None
|
||||
return
|
||||
|
||||
quotadef = data[1][0]
|
||||
m = re.match("[^\s]+ \(STORAGE (\d+) (\d+)\)", quotadef)
|
||||
if not m:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{% load i18n %}
|
||||
{% load i18n libextras %}
|
||||
<form method="POST" action="{{ posturl }}" id="composemail">
|
||||
<div id="compose-container">
|
||||
<div id="mailheader">
|
||||
{% include "common/genericform.html" %}
|
||||
{% render_form form %}
|
||||
<div id="attachments" name="{% url modoboa.extensions.webmail.views.attachments %}">
|
||||
<div>
|
||||
<img src="{{ MEDIA_URL }}pics/attachment.png" />
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
{% load i18n %}
|
||||
{% load webextras %}
|
||||
{% if titlebar %}
|
||||
<div class="boxtitle">
|
||||
<a href="{% url modoboa.extensions.webmail.views.newfolder %}" class="boxed"
|
||||
rel="{handler: 'iframe', size: {x: 350, y: 400}, closeBtn: true}">
|
||||
<img src="{{MEDIA_URL}}pics/add.png"
|
||||
alt="{% trans 'Add a new folder' %}"/>
|
||||
</a>
|
||||
<label class="aligned">{% trans "Folders" %}</label>
|
||||
<div class="spacer"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<ul>
|
||||
<ul class="nav nav-list">
|
||||
{% if titlebar %}
|
||||
<li class="nav-header">
|
||||
<a href="{% url modoboa.extensions.webmail.views.newfolder %}">
|
||||
<i class="icon-plus"></i>
|
||||
{% trans "Folders" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% print_folders folders selected withunseen withmenu %}
|
||||
</ul>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{% extends "common/mailheaders.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block extraheaders %}
|
||||
{% if attachments %}
|
||||
<tr>
|
||||
|
||||
@@ -50,7 +50,7 @@ def viewmail_menu(selection, folder, user, mail_id=None):
|
||||
}
|
||||
]
|
||||
|
||||
return render_to_string('common/menu.html',
|
||||
return render_to_string('common/buttons_list.html',
|
||||
{"selection" : selection, "entries" : entries,
|
||||
"user" : user})
|
||||
|
||||
@@ -66,7 +66,7 @@ def compose_menu(selection, backurl, user):
|
||||
"img" : static_url("pics/send-receive.png"),
|
||||
"label" : _("Send")},
|
||||
]
|
||||
return render_to_string('common/menu.html',
|
||||
return render_to_string('common/buttons_list.html',
|
||||
{"selection" : selection, "entries" : entries,
|
||||
"user" : user})
|
||||
|
||||
@@ -74,13 +74,13 @@ def compose_menu(selection, backurl, user):
|
||||
def listmailbox_menu(selection, folder, user):
|
||||
entries = [
|
||||
{"name" : "compose",
|
||||
"url" : "compose",
|
||||
"img" : static_url("pics/edit.png"),
|
||||
"label" : _("New message")},
|
||||
"url" : "compose",
|
||||
"label" : _("New message"),
|
||||
"class" : "btn"},
|
||||
{"name" : "mark",
|
||||
"img" : static_url("pics/domains.png"),
|
||||
|
||||
"label" : _("Mark messages"),
|
||||
"class" : "menubardropdown",
|
||||
"class" : "btn",
|
||||
"menu" : [
|
||||
{"name" : "mark-read",
|
||||
"label" : _("As read"),
|
||||
@@ -93,8 +93,7 @@ def listmailbox_menu(selection, folder, user):
|
||||
{"name" : "actions",
|
||||
"img" : static_url("pics/settings.png"),
|
||||
"label" : _("Actions"),
|
||||
"class" : "menubardropdown",
|
||||
"width" : "150",
|
||||
"class" : "btn",
|
||||
"menu" : [
|
||||
{"name" : "fdaction",
|
||||
"label" : _("Compress folder"),
|
||||
@@ -110,24 +109,25 @@ def listmailbox_menu(selection, folder, user):
|
||||
"img" : static_url("pics/clear.png"),
|
||||
"url" : reverse(webmail.views.empty, args=[folder])}
|
||||
]
|
||||
menu = render_to_string("common/menu.html",
|
||||
menu = render_to_string("common/buttons_list.html",
|
||||
{"selection" : selection, "entries" : entries,
|
||||
"user" : user})
|
||||
searchbar = render_to_string("common/email_searchbar.html", {
|
||||
"MEDIA_URL" : settings.MEDIA_URL
|
||||
})
|
||||
return menu + searchbar
|
||||
"user" : user, "css" : "nav"})
|
||||
# searchbar = render_to_string("common/email_searchbar.html", {
|
||||
# "MEDIA_URL" : settings.MEDIA_URL
|
||||
# })
|
||||
# return menu + searchbar
|
||||
return menu
|
||||
|
||||
@register.simple_tag
|
||||
def print_folders(folders, selected=None, withunseen=False, withmenu=False):
|
||||
result = ""
|
||||
|
||||
for fd in folders:
|
||||
cssclass = fd["class"] if fd.has_key("class") else "folder"
|
||||
cssclass = ""
|
||||
name = fd["path"] if fd.has_key("sub") else fd["name"]
|
||||
label = fd["name"]
|
||||
if selected == name:
|
||||
cssclass += " selected"
|
||||
cssclass = "active"
|
||||
result += "<li name='%s' class='droppable %s'>\n" % (name, cssclass)
|
||||
if fd.has_key("sub"):
|
||||
if selected is not None and selected != name and selected.count(name):
|
||||
@@ -136,17 +136,21 @@ def print_folders(folders, selected=None, withunseen=False, withmenu=False):
|
||||
else:
|
||||
ul_state = "hidden"
|
||||
div_state = "collapsed"
|
||||
result += "<div class='clickbox %s'> </div>" % div_state
|
||||
if withmenu:
|
||||
result += "<img src='%spics/go-down.png' class='footer' />" \
|
||||
% settings.MEDIA_URL
|
||||
result += "<div class='clickbox %s'></div>" % div_state
|
||||
# if withmenu:
|
||||
# result += "<img src='%spics/go-down.png' class='footer' />" \
|
||||
# % settings.MEDIA_URL
|
||||
|
||||
cssclass = "block"
|
||||
if withunseen and fd.has_key("unseen"):
|
||||
label += " (%d)" % fd["unseen"]
|
||||
cssclass += " unseen"
|
||||
result += "<a href='%s' class='%s' name='loadfolder'>%s</a>\n" \
|
||||
% (fd.has_key("path") and fd["path"] or fd["name"], cssclass, label)
|
||||
iclass = fd["class"] if fd.has_key("class") else "icon-folder-close"
|
||||
result += """<a href='%s' class='%s' name='loadfolder'>
|
||||
<i class="%s"></i>
|
||||
%s
|
||||
</a>
|
||||
""" % (fd.has_key("path") and fd["path"] or fd["name"], cssclass, iclass, label)
|
||||
if fd.has_key("sub") and len(fd["sub"]):
|
||||
result += "<ul name='%s' class='%s'>" % (fd["path"], ul_state) \
|
||||
+ print_folders(fd["sub"], selected, withunseen, withmenu) + "</ul>\n"
|
||||
|
||||
@@ -526,7 +526,7 @@ def viewmail(request):
|
||||
url = reverse(getmailcontent) + "?mbox=%s&mailid=%s&links=%d" % \
|
||||
(request.session["mbox"], mailid, links)
|
||||
content = Template("""
|
||||
<iframe width="100%" frameBorder="0" src="{{ url }}" id="mailcontent"></iframe>
|
||||
<iframe src="{{ url }}" id="mailcontent"></iframe>
|
||||
""").render(Context({"url" : url}))
|
||||
|
||||
return dict(listing=content, menuargs=dict(mail_id=mailid))
|
||||
@@ -571,7 +571,7 @@ def newindex(request):
|
||||
else:
|
||||
if request.is_ajax():
|
||||
raise WebmailError(_("Bad request"))
|
||||
response = dict(deflocation="?action=listmailbox",
|
||||
response = dict(selection="webmail", deflocation="?action=listmailbox",
|
||||
defcallback="wm_updatelisting")
|
||||
|
||||
curmbox = request.session.get("mbox", "INBOX")
|
||||
@@ -582,7 +582,7 @@ def newindex(request):
|
||||
int(parameters.get_user(request.user, "REFRESH_INTERVAL")) * 1000
|
||||
response["mboxes"] = render_mboxes_list(request, imapc)
|
||||
response["quota"] = ImapListing.computequota(imapc)
|
||||
return _render(request, "webmail/index.html", response)
|
||||
return _render(request, "webmail/index2.html", response)
|
||||
|
||||
if action in ["reply", "forward"]:
|
||||
action = "compose"
|
||||
|
||||
Reference in New Issue
Block a user