mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-19 05:58:34 +02:00
@@ -61,6 +61,7 @@ Webmail.prototype = {
|
||||
$(window).resize(this.resize);
|
||||
|
||||
$(document).on("click", "a[name=compose]", $.proxy(this.compose_loader, this));
|
||||
$(document).on("click", "a[name=totrash]", $.proxy(this.delete_messages, this));
|
||||
$(document).on("click", "a[name*=mark-]", $.proxy(this.send_mark_request, this));
|
||||
$(document).on("click", "a[name=compress]", $.proxy(this.compress, this));
|
||||
$(document).on("click", "a[name=empty]", $.proxy(this.empty, this));
|
||||
@@ -146,7 +147,7 @@ Webmail.prototype = {
|
||||
this.navobject.reset()
|
||||
.setparams({action: "listmailbox", mbox: curmb});
|
||||
this.restore_nav_params();
|
||||
this.navobject.update();
|
||||
this.navobject.update(true);
|
||||
},
|
||||
|
||||
/*
|
||||
@@ -639,7 +640,25 @@ Webmail.prototype = {
|
||||
e.preventDefault();
|
||||
$.ajax({
|
||||
url: $link.attr("href"),
|
||||
dataType: 'json',
|
||||
success: $.proxy(this.delete_callback, this)
|
||||
});
|
||||
},
|
||||
|
||||
delete_messages: function(e) {
|
||||
e.preventDefault();
|
||||
var $link = get_target(e, "a");
|
||||
var msgs = this.htmltable.current_selection();
|
||||
var selection = [];
|
||||
|
||||
if (!msgs.length) {
|
||||
return;
|
||||
}
|
||||
$.each(msgs, function(idx, item) {
|
||||
selection.push($(item).attr("id"));
|
||||
});
|
||||
$.ajax({
|
||||
url: $link.attr("href"),
|
||||
data: {mbox: this.get_current_mailbox(), selection: selection},
|
||||
success: $.proxy(this.delete_callback, this)
|
||||
});
|
||||
},
|
||||
@@ -852,8 +871,9 @@ Webmail.prototype = {
|
||||
|
||||
delete_callback: function(data) {
|
||||
if (data.status == "ok") {
|
||||
var msg = (data.respmsg) ? data.respmsg : gettext("Message deleted");
|
||||
this.go_back_to_listing();
|
||||
$("body").notify("success", gettext("Message deleted"), 2000);
|
||||
$("body").notify("success", msg, 2000);
|
||||
} else {
|
||||
$("body").notify("error", data.respmsg);
|
||||
}
|
||||
@@ -1006,7 +1026,7 @@ Webmail.prototype = {
|
||||
'class': "well dragbox"
|
||||
})
|
||||
.appendTo($(document.body))
|
||||
.css({
|
||||
.offset({
|
||||
top: $this.offset().top,
|
||||
left: $this.offset().left
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ def viewmail_menu(selection, folder, user, mail_id=None):
|
||||
"label" : _("Forward")},
|
||||
{"name" : "delete",
|
||||
"img" : "icon-trash",
|
||||
"url" : reverse(webmail.views.delete) + "?mbox=%s&mailid=%s" % (folder, mail_id),
|
||||
"url" : reverse(webmail.views.delete) + "?mbox=%s&selection[]=%s" % (folder, mail_id),
|
||||
"label" : _("Delete")},
|
||||
{"name" : "display_options",
|
||||
"label" : _("Display options"),
|
||||
@@ -75,6 +75,12 @@ def listmailbox_menu(selection, folder, user):
|
||||
"img" : "icon-edit",
|
||||
"label" : _("New message"),
|
||||
"class" : "btn"},
|
||||
{"name": "totrash",
|
||||
"label": "",
|
||||
"class": "btn",
|
||||
"img": "icon-trash",
|
||||
"url": reverse("modoboa.extensions.webmail.views.delete"),
|
||||
},
|
||||
{"name" : "mark",
|
||||
"label" : _("Mark messages"),
|
||||
"class" : "btn",
|
||||
@@ -95,7 +101,7 @@ def listmailbox_menu(selection, folder, user):
|
||||
"label" : _("Compress folder"),
|
||||
"url" : "compact/%s/" % folder}
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
||||
if folder == parameters.get_user(user, "TRASH_FOLDER"):
|
||||
entries[2]["menu"] += [
|
||||
|
||||
@@ -3,7 +3,7 @@ from django.conf import settings
|
||||
import os
|
||||
from django.http import HttpResponse
|
||||
from django.template import Template, Context
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ugettext as _, ungettext
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from modoboa.lib import parameters
|
||||
@@ -72,12 +72,16 @@ def move(request):
|
||||
@needs_mailbox()
|
||||
def delete(request):
|
||||
mbox = request.GET.get("mbox", None)
|
||||
mailid = request.GET.get("mailid", None)
|
||||
if mbox is None or mailid is None:
|
||||
selection = request.GET.getlist("selection[]", None)
|
||||
if mbox is None or selection is None:
|
||||
raise WebmailError(_("Invalid request"))
|
||||
selection = [item for item in selection if item.isdigit()]
|
||||
mbc = get_imapconnector(request)
|
||||
mbc.move(mailid, mbox, parameters.get_user(request.user, "TRASH_FOLDER"))
|
||||
resp = dict(status="ok")
|
||||
mbc.move(",".join(selection), mbox, parameters.get_user(request.user, "TRASH_FOLDER"))
|
||||
message = ungettext("%(count)d message deleted",
|
||||
"%(count)d messages deleted",
|
||||
len(selection)) % {"count": len(selection)}
|
||||
resp = dict(status="ok", respmsg=message)
|
||||
return ajax_simple_response(resp)
|
||||
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user