Display the name of the object about to be deleted.

fixes #483
This commit is contained in:
Antoine Nguyen
2013-09-19 21:12:50 +02:00
parent 98f3bbda0f
commit f5626ecaa6
6 changed files with 29 additions and 65 deletions
+3 -13
View File
@@ -114,7 +114,7 @@ Domains.prototype = {
: gettext("This operation will remove all data associated to this domain, excepting accounts.");
$("a[name=deldomain]").confirm({
question: gettext("Delete this domain?"),
question: function() { return this.$element.attr('title'); },
method: "POST",
warning: warnmsg,
checkboxes: deloptions,
@@ -240,23 +240,13 @@ Identities.prototype = {
$("a.filter").click($.proxy(this.filter_by_tag, this));
$("a[name=delaccount]").confirm({
question: gettext("Delete this account?"),
question: function() { return this.$element.attr('title'); },
method: "POST",
checkboxes: deloptions,
success_cb: $.proxy(this.reload_listing, this)
});
$("a[name=deldlist]").confirm({
question: gettext("Delete this list?"),
method: "DELETE",
success_cb: $.proxy(this.reload_listing, this)
});
$("a[name=delforward]").confirm({
question: gettext("Delete this forward?"),
method: "DELETE",
success_cb: $.proxy(this.reload_listing, this)
});
$("a[name=delalias]").confirm({
question: gettext("Delete this alias?"),
question: function() { return this.$element.attr('title'); },
method: "DELETE",
success_cb: $.proxy(this.reload_listing, this)
});
+8 -23
View File
@@ -175,7 +175,7 @@ def domain_actions(user, domid):
actions.append({
"name": "deldomain",
"url": reverse("modoboa.admin.views.deldomain", args=[domid]),
"title": _("Delete the domain"),
"title": _("Delete %s?" % domain.name),
"img": "icon-trash"
})
return render_actions(actions)
@@ -191,30 +191,15 @@ def identity_actions(user, ident):
{"name" : "delaccount",
"url" : reverse("modoboa.admin.views.delaccount", args=[objid]),
"img" : "icon-trash",
"title" : _("Delete this account")},
"title" : _("Delete %s?" % ident.username)},
]
else:
if ident.get_recipients_count() >= 2:
actions = [
{"name" : "deldlist",
"url" : reverse("modoboa.admin.views.deldlist") + "?selection=%s" % objid,
"img" : "icon-trash",
"title" : _("Delete this distribution list")},
]
elif ident.extmboxes != "":
actions = [
{"name" : "delforward",
"url" : reverse("modoboa.admin.views.delforward") + "?selection=%s" % objid,
"img" : "icon-trash",
"title" : _("Delete this forward")},
]
else:
actions = [
{"name" : "delalias",
"url" : reverse("modoboa.admin.views.delalias") + "?selection=%s" % objid,
"img" : "icon-trash",
"title" : _("Delete this alias")},
]
actions = [
{"name" : "delalias",
"url" : reverse("modoboa.admin.views.delalias") + "?selection=%s" % objid,
"img" : "icon-trash",
"title" : _("Delete %s?" % ident.full_address)},
]
return render_actions(actions)
@register.simple_tag
+2 -2
View File
@@ -208,7 +208,7 @@ class AliasTestCase(ModoTestCase):
values)
self.assertEqual(dlist.get_recipients_count(), 2)
self.check_ajax_get(reverse("modoboa.admin.views.deldlist") + "?selection=%d" \
self.check_ajax_get(reverse("modoboa.admin.views.delalias") + "?selection=%d" \
% dlist.id, {})
self.assertRaises(Alias.DoesNotExist, Alias.objects.get,
address="all", domain__name="test.com")
@@ -224,7 +224,7 @@ class AliasTestCase(ModoTestCase):
values)
self.assertEqual(fwd.get_recipients_count(), 1)
self.check_ajax_get(reverse("modoboa.admin.views.delforward") + "?selection=%d" \
self.check_ajax_get(reverse("modoboa.admin.views.delalias") + "?selection=%d" \
% fwd.id, {})
self.assertRaises(Alias.DoesNotExist, Alias.objects.get,
address="forward", domain__name="test.com")
-3
View File
@@ -35,10 +35,7 @@ urlpatterns = patterns(
(r'^accounts/delete/(?P<accountid>\d+)/$', 'delaccount'),
(r'^distriblists/new/$', 'newdlist'),
(r'^distriblists/delete/$', 'deldlist'),
(r'^forwards/new/$', 'newforward'),
(r'^forwards/delete/$', 'delforward'),
(r'^aliases/new/$', 'newalias'),
(r'^aliases/edit/(?P<alid>\d+)/$', 'editalias'),
+13 -23
View File
@@ -300,40 +300,30 @@ def editalias(request, alid, tplname="common/generic_modal_form.html"):
return render(request, tplname, ctx)
def _del_alias(request, msg, msgs):
@login_required
@permission_required("admin.delete_alias")
@transaction.commit_on_success
def delalias(request):
selection = request.GET["selection"].split(",")
for alid in selection:
alias = Alias.objects.get(pk=alid)
if not request.user.can_access(alias):
raise PermDeniedException
if alias.type == 'dlist':
msg = "Distribution list deleted"
msgs = "Distribution lists deleted"
elif alias.type == 'forward':
msg = "Forward deleted"
msgs = "Forwards deleted"
else:
msg = "Alias deleted"
msgs = "Aliases deleted"
alias.delete()
msg = ungettext(msg, msgs, len(selection))
return ajax_simple_response({"status": "ok", "respmsg": msg})
@login_required
@permission_required("admin.delete_alias")
@transaction.commit_on_success
def delalias(request):
return _del_alias(request, "Alias deleted", "Aliases deleted")
@login_required
@permission_required("admin.delete_alias")
@transaction.commit_on_success
def deldlist(request):
return _del_alias(request, "Distribution list deleted",
"Distribution lists deleted")
@login_required
@permission_required("admin.delete_alias")
@transaction.commit_on_success
def delforward(request):
return _del_alias(request, "Forward deleted", "Forwards deleted")
@login_required
@user_passes_test(lambda u: u.has_perm("admin.add_user") or u.has_perm("admin.add_alias"))
def _identities(request):
+3 -1
View File
@@ -36,9 +36,11 @@
id: "confirmbox",
'class': "modal"
});
var question = (typeof this.options.question == 'function')
? this.options.question.apply(this) : this.options.question;
box.append($('<div class="modal-body">'
+ '<h4>' + this.options.question + '</h4>'));
+ '<h4>' + question + '</h4>'));
var $container = $("<div />", {"class" : "container-fluid"});
box.append($container);
if (this.options.warning) {