diff --git a/forms.py b/forms.py
index cb410cf..b326224 100644
--- a/forms.py
+++ b/forms.py
@@ -196,7 +196,16 @@
#initial = 'subscribe',
)
- # should add password!
+ # should add password! TODO
+ class Meta:
+ """
+ Class to handle the automatic insertion of fieldsets and divs.
+
+ To use it: add a list for each wished fieldset. The first item in
+ the list should be the wished name of the fieldset, the following
+ the fields that should be included in the fieldset.
+ """
+ layout = [["Subscribe", "email","real_name"]]
class ListUnsubscribe(forms.Form):
"""Form fields to leave an existing list.
@@ -221,8 +230,17 @@
widget = forms.HiddenInput(),
#initial = 'unsubscribe'
)
+ class Meta:
+ """
+ Class to handle the automatic insertion of fieldsets and divs.
+
+ To use it: add a list for each wished fieldset. The first item in
+ the list should be the wished name of the fieldset, the following
+ the fields that should be included in the fieldset.
+ """
+ layout = [["Unsubscribe", "email"]]
- # should at one point add the password to be required as well!
+ # should at one point add the password to be required as well! #TODO
class ListSettings(FieldsetForm):
"""Form fields dealing with the list settings.
"""
diff --git a/templates/mailman-django/lists/index.html b/templates/mailman-django/lists/index.html
index c67785d..3a236ae 100644
--- a/templates/mailman-django/lists/index.html
+++ b/templates/mailman-django/lists/index.html
@@ -17,7 +17,7 @@
{{ list.real_name }} |
{{ list.fqdn_listname }} |
- {%trans "Info / Subscribe" %}
+ {%trans "Info / Subscribe" %}
|
{%trans "Settings" %}
@@ -25,10 +25,6 @@
|
{%trans "Delete list" %}
|
-
{% endfor %}
diff --git a/templates/mailman-django/lists/info.html b/templates/mailman-django/lists/info.html
deleted file mode 100644
index df80e09..0000000
--- a/templates/mailman-django/lists/info.html
+++ /dev/null
@@ -1,68 +0,0 @@
-{% extends "mailman-django/base.html" %}
-{% load i18n %}
-
-{% block content %}
-
-{{ fqdn_listname }} -- {{ listinfo.real_name }}
-
-{% trans 'List information' %}
-
-{% trans 'A bit of information to make people want to subscribe...' %}
-
-
-
-
-
-
-
-
-
-{% endblock %}
diff --git a/templates/mailman-django/lists/info.html_old b/templates/mailman-django/lists/info.html_old
new file mode 100644
index 0000000..df80e09
--- /dev/null
+++ b/templates/mailman-django/lists/info.html_old
@@ -0,0 +1,68 @@
+{% extends "mailman-django/base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+{{ fqdn_listname }} -- {{ listinfo.real_name }}
+
+{% trans 'List information' %}
+
+{% trans 'A bit of information to make people want to subscribe...' %}
+
+
+
+
+
+
+
+
+
+{% endblock %}
diff --git a/templates/mailman-django/lists/subscriptions.html b/templates/mailman-django/lists/subscriptions.html
new file mode 100644
index 0000000..0da5094
--- /dev/null
+++ b/templates/mailman-django/lists/subscriptions.html
@@ -0,0 +1,66 @@
+{% extends "mailman-django/base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+{{ fqdn_listname }} -- {{ listinfo.real_name }}
+
+{% if form_subscribe %}
+
+{% endif %}
+{% if form_unsubscribe %}
+
+{% endif %}
+
+
+
+{% endblock %}
diff --git a/templates/mailman-django/menu/administration.html b/templates/mailman-django/menu/administration.html
index e3328cc..ecb39b4 100644
--- a/templates/mailman-django/menu/administration.html
+++ b/templates/mailman-django/menu/administration.html
@@ -8,6 +8,11 @@
{% trans "Domains" %}
+
+
+ {% trans "All Lists" %}
+
+
{% trans "New List" %}
diff --git a/templates/mailman-django/menu/subscriptions.html b/templates/mailman-django/menu/subscriptions.html
index c851683..1940bad 100644
--- a/templates/mailman-django/menu/subscriptions.html
+++ b/templates/mailman-django/menu/subscriptions.html
@@ -1,7 +1,8 @@
{% load i18n %}
{% block menu_subscriptions %}
- {% trans "Subscriptions" %}
+ {% if fqdn_listname %}
+ {% trans "Subscriptions" %}
+ {%endif%}
{% endblock%}
diff --git a/urls.py b/urls.py
index 42a2e8f..588ea04 100644
--- a/urls.py
+++ b/urls.py
@@ -26,7 +26,10 @@
url(r'^lists/$', 'list_index', name = 'list_index'),
url(r'^lists/new/$', 'list_new', name = 'list_new'),
url(r'^lists/logout/$', 'logout', name = 'logout'),
- url(r'^lists/(?P.+)/$', 'list_info', name = 'list_info'),
+ url(r'^lists/(?P[^/]+)/$', 'list_subscriptions', name = 'list_info'),
+ url(r'^lists/(?P.+)/subscriptions/$', 'list_subscriptions', kwargs={"option": None}, name = 'list_subscriptions'),
+ url(r'^lists/(?P.+)/subscriptions/subscribe$', 'list_subscriptions', kwargs={"option": "subscribe"}, name = 'list_subscriptions'),
+ url(r'^lists/(?P.+)/subscriptions/unsubscribe$', 'list_subscriptions', kwargs={"option": "unsubscribe"}, name = 'list_subscriptions'),
url(r'^delete_list/(?P[^/]+)/$', 'list_delete', name = 'list_delete'),
url(r'^user_settings/(?P[^/]+)/$', 'user_settings', kwargs={"tab": "user"}, name = 'user_settings'),
url(r'^membership_settings/(?P[^/]+)/$', 'user_settings', kwargs={"tab": "membership"}, name = 'membership_settings'),
diff --git a/views.py b/views.py
index 73619c4..a56063a 100644
--- a/views.py
+++ b/views.py
@@ -201,8 +201,8 @@
{'message': "Unexpected error:"+ e.message},context_instance=RequestContext(request))
-def list_info(request, fqdn_listname = None,
- template = 'mailman-django/lists/info.html'):
+def list_subscriptions(request, fqdn_listname = None,
+ template = 'mailman-django/lists/subscriptions.html',option="",*args, **kwargs):
"""
Display the information there is available for a list. This
function also enables subscribing or unsubscribing a user to a
@@ -214,58 +214,58 @@
the_list = c.get_list(fqdn_listname)
except Exception, e:
return HttpResponse(e)
+ if option:
+ if option == "subscribe":
+ form_subscribe = ListSubscribe()
+ if option == "unsubscribe":
+ form_unsubscribe = ListUnsubscribe()
+ else:
+ form_subscribe = None
+ form_unsubscribe = None
+
if request.method == 'POST':
form = False
# The form enables both subscribe and unsubscribe. As a result
# we must find out which was the case.
action = request.POST.get('name', '')
+
if action == "subscribe":
form = ListSubscribe(request.POST)
+ if form.is_valid():
+ # the form was valid so try to subscribe the user
+ fqdn_listname = form.cleaned_data['listname']
+ try:
+ response = the_list.subscribe(address=form.cleaned_data['email'],real_name=form.cleaned_data.get('real_name', ''))
+ return HttpResponseRedirect(reverse('list_subscriptions'))
+ except Exception, e:
+ return HttpResponse(e)
+ else:
+ form_subscribe = ListSubscribe(request.POST)
+ form_unsubscribe = ListUnsubscribe(initial = {'fqdn_listname': fqdn_listname, 'name' : 'unsubscribe'})
elif action == "unsubscribe":
form = ListUnsubscribe(request.POST)
- if form and form.is_valid():
- listname = form.cleaned_data['listname']
- email = form.cleaned_data['email']
- if action == "subscribe":
- real_name = form.cleaned_data.get('real_name', '')
- try:
- # the form was valid so try to subscribe the user
- response = the_list.subscribe(address=email,
- real_name=real_name)
- return HttpResponseRedirect(reverse('list_index'))
- except Exception, e:
- return HttpResponse(e)
- elif action == "unsubscribe":
- # the form was valid so try to unsubscribe the user
+ if form.is_valid():
+ #the form was valid so try to unsubscribe the user
try:
response = the_list.unsubscribe(address=email)
- template = 'mailman-django/lists/unsubscribed.html'
- return render_to_response(template,
- {'listname': fqdn_listname},context_instance=RequestContext(request))
+ return render_to_response('mailman-django/lists/unsubscribed.html',
+ {'fqdn_listname': fqdn_listname},context_instance=RequestContext(request))
except Exception, e:
- return HttpResponse(e)
- else:
- # the user tried to post an incorrect form so make sure we
- # return the filled in values and let the user try again.
- if action == "subscribe":
- subscribe = ListSubscribe(request.POST)
- unsubscribe = ListUnsubscribe(initial = {'listname': fqdn_listname,
- 'name' : 'unsubscribe'})
- elif action == "unsubscribe":
- subscribe = ListSubscribe(initial = {'listname': fqdn_listname,
- 'name' : 'subscribe'})
- unsubscribe = ListUnsubscribe(request.POST)
+ return HttpResponse(e)
+ else:
+ form_subscribe = ListSubscribe(initial = {'fqdn_listname': fqdn_listname, 'name' : 'subscribe'})
+ form_unsubscribe = ListUnsubscribe(request.POST)
+
else:
# the request was a GET request so set the two forms to empty
# forms
- subscribe = ListSubscribe(initial = {'listname': fqdn_listname,
+ form_subscribe = ListSubscribe(initial = {'fqdn_listname': fqdn_listname,
'name' : 'subscribe'})
- unsubscribe = ListUnsubscribe(initial = {'listname': fqdn_listname,
+ form_unsubscribe = ListUnsubscribe(initial = {'fqdn_listname': fqdn_listname,
'name' : 'unsubscribe'})
-
- listinfo = c.get_list(fqdn_listname)
- return render_to_response(template, {'subscribe': subscribe,
- 'unsubscribe': unsubscribe,
+ listinfo = c.get_list(fqdn_listname)#TODO
+ return render_to_response(template, {'form_subscribe': form_subscribe,
+ 'form_unsubscribe': form_unsubscribe,
'fqdn_listname': fqdn_listname,
'listinfo': listinfo}
,context_instance=RequestContext(request))
@@ -411,7 +411,7 @@
"""
message = ""
membership_lists = []
- listname = ""
+ fqdn_listname = ""
try:
c = Client('http://localhost:8001/3.0', API_USER, API_PASS)
user_object = c.get_user(member)
@@ -446,9 +446,9 @@
else:
if tab == "membership":
- listname = request.GET.get("list", "")
- if listname:
- member_object = c.get_member(member, listname)
+ fqdn_listname = request.GET.get("list", "")
+ if fqdn_listname:
+ member_object = c.get_member(member, fqdn_listname)
# TODO: add delivery_mode and deliver_status from a
# list of tuples at one point, currently we hard code
# them in forms.py
@@ -467,7 +467,7 @@
return render_to_response(template, {'form': form,
'tab': tab,
- 'listname': listname,
+ 'fqdn_listname': fqdn_listname,
'membership_lists': membership_lists,
'message': message,
'member': member}