Skip to content

Commit

Permalink
Merge pull request #2755 from modoboa/fix/delete_alias_method
Browse files Browse the repository at this point in the history
Ensure DELETE method for delete alias view
  • Loading branch information
tonioo committed Jan 23, 2023
2 parents 1a69db1 + f61c452 commit 883cb4c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
7 changes: 3 additions & 4 deletions modoboa/admin/tests/test_alias.py
Expand Up @@ -156,10 +156,9 @@ def test_dlist(self):
)
self.assertEqual(dlist.recipients_count, 2)

self.ajax_post(
self.ajax_delete(
"{}?selection={}".format(
reverse("admin:alias_delete"), dlist.id),
{}
reverse("admin:alias_delete"), dlist.id)
)
self.assertRaises(
Alias.DoesNotExist, Alias.objects.get, address="all@test.com")
Expand All @@ -180,7 +179,7 @@ def test_forward(self):
)
self.assertEqual(fwd.recipients_count, 1)

self.ajax_post(
self.ajax_delete(
reverse("admin:alias_delete") + "?selection=%d"
% fwd.id, {}
)
Expand Down
2 changes: 2 additions & 0 deletions modoboa/admin/views/alias.py
Expand Up @@ -9,6 +9,7 @@
from django.urls import reverse
from django.utils.translation import ugettext as _, ungettext
from django.views import generic
from django.views.decorators.http import require_http_methods

from modoboa.core import signals as core_signals
from modoboa.lib.exceptions import Conflict, PermDeniedException
Expand Down Expand Up @@ -93,6 +94,7 @@ def editalias(request, alid, tplname="admin/aliasform.html"):

@login_required
@permission_required("admin.delete_alias")
@require_http_methods(["DELETE"])
def delalias(request):
selection = request.GET["selection"].split(",")
for alid in selection:
Expand Down
5 changes: 2 additions & 3 deletions modoboa/limits/tests/test_user_limits.py
Expand Up @@ -162,10 +162,9 @@ def test_aliases_limit(self):
max_value=-1)
self._create_alias("alias3@test.com")
self._check_limit("mailbox_aliases", 3, -1)
self.ajax_post(
self.ajax_delete(
reverse("admin:alias_delete") + "?selection=%d"
% Alias.objects.get(address="alias2@test.com").id,
{}
% Alias.objects.get(address="alias2@test.com").id
)
self._check_limit("mailbox_aliases", 2, -1)

Expand Down

0 comments on commit 883cb4c

Please sign in to comment.