diff --git a/src/postorius/doc/news.rst b/src/postorius/doc/news.rst
index 8c6abf4..0f52eca 100644
--- a/src/postorius/doc/news.rst
+++ b/src/postorius/doc/news.rst
@@ -47,6 +47,7 @@
* added a favicon. Contributed by Richard Wackerbarth.
* renamed some menu items. Contributed by Richard Wackerbarth.
* changed static file inclusion. Contributed by Richard Wackerbarth.
+* added delete domain feature.
diff --git a/src/postorius/templates/postorius/domain_confirm_delete.html b/src/postorius/templates/postorius/domain_confirm_delete.html
new file mode 100644
index 0000000..df40cfe
--- /dev/null
+++ b/src/postorius/templates/postorius/domain_confirm_delete.html
@@ -0,0 +1,12 @@
+{% extends extend_template %}
+{% load url from future %}
+{% load i18n %}
+{% load nav_helpers %}
+
+{% block main %}
+
{% trans "Are you sure you want to permanently delete this Domain?" %}
+
+{% endblock main %}
diff --git a/src/postorius/templates/postorius/domain_index.html b/src/postorius/templates/postorius/domain_index.html
index a7aa2aa..3feaf29 100644
--- a/src/postorius/templates/postorius/domain_index.html
+++ b/src/postorius/templates/postorius/domain_index.html
@@ -23,7 +23,7 @@
{{ domain.base_url }} |
{{ domain.contact_address }} |
{{ domain.description }} |
- {% trans 'Delete' %} |
+ {% trans 'Delete' %} |
{% endfor %}
diff --git a/src/postorius/urls.py b/src/postorius/urls.py
index a319d03..ce12b7e 100644
--- a/src/postorius/urls.py
+++ b/src/postorius/urls.py
@@ -26,7 +26,7 @@
urlpatterns = patterns(
'postorius.views',
- (r'^$', 'list_index'),
+ (r'^$', 'list_index'),
# /account/
url(r'^accounts/login/$', 'user_login', name='user_login'),
url(r'^accounts/logout/$', 'user_logout', name='user_logout'),
@@ -41,6 +41,8 @@
url(r'^settings/$', 'site_settings', name="site_settings"),
url(r'^settings/domains/$', 'domain_index', name='domain_index'),
url(r'^settings/domains/new/$', 'domain_new', name='domain_new'),
+ url(r'^settings/domains/(?P[^/]+)/delete$',
+ 'domain_delete', name='domain_delete'),
# /lists/
url(r'^lists/$', 'list_index', name='list_index'),
url(r'^lists/new/$', 'list_new', name='list_new'),
@@ -76,7 +78,7 @@
'(?:/(?P.*))?$', 'list_settings',
name='list_settings'),
# /users/
- url(r'^users/$', 'user_index', name='user_index'),
+ url(r'^users/$', 'user_index', name='user_index'),
url(r'^users/new/$', 'user_new', name='user_new'),
url(r'^users/(?P[^/]+)/$',
UserSummaryView.as_view(), name='user_summary'),
diff --git a/src/postorius/views/settings.py b/src/postorius/views/settings.py
index 97d65bd..333191d 100644
--- a/src/postorius/views/settings.py
+++ b/src/postorius/views/settings.py
@@ -17,10 +17,7 @@
# Postorius. If not, see .
-import re
-import sys
import json
-import logging
from django.conf import settings
@@ -49,9 +46,6 @@
from postorius.views.generic import MailingListView, MailmanUserView
-logger = logging.getLogger(__name__)
-
-
@login_required
@user_passes_test(lambda u: u.is_superuser)
def site_settings(request):
@@ -95,3 +89,25 @@
return render_to_response('postorius/domain_new.html',
{'form': form, 'message': message},
context_instance=RequestContext(request))
+
+def domain_delete(request, domain):
+ """Deletes a domain but asks for confirmation first.
+ """
+ if request.method == 'POST':
+ try:
+ client = Client(settings.REST_SERVER + '/3.0', settings.API_USER,
+ settings.API_PASS)
+ client.delete_domain(domain)
+ messages.success(request,
+ _('The domain %s has been deleted.' % domain))
+ return redirect("domain_index")
+ except HTTPError as e:
+ print e.__dict__
+ messages.error(request, _('The domain could not be deleted:'
+ ' %s' % e.msg))
+ return redirect("domain_index")
+ submit_url = reverse('domain_delete',
+ kwargs={'domain': domain})
+ return render_to_response('postorius/domain_confirm_delete.html',
+ {'domain': domain, 'submit_url': submit_url},
+ context_instance=RequestContext(request))