diff --git a/forms.py b/forms.py index 04aa37c..c940632 100644 --- a/forms.py +++ b/forms.py @@ -174,8 +174,8 @@ class ListSubscribe(FieldsetForm): """Form fields to join an existing list. """ - listname = forms.EmailField( - label = _('List Name'), + fqdn_listname = forms.EmailField( + label = '',#_('List Name'), widget = forms.HiddenInput(), error_messages = { 'required': _('Please enter the mailing list address.'), @@ -204,13 +204,13 @@ 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","name"]] + layout = [["Subscribe", "email","real_name","name","fqdn_listname"]] class ListUnsubscribe(FieldsetForm): """Form fields to leave an existing list. """ - listname = forms.EmailField( - label = _('List Name'), + fqdn_listname = forms.EmailField( + label = '',#_('List Name'), widget = forms.HiddenInput(), error_messages = { 'required': _('Please enter the mailing list address.'), @@ -237,7 +237,7 @@ the list should be the wished name of the fieldset, the following the fields that should be included in the fieldset. """ - layout = [["Unsubscribe", "email","name"]] + layout = [["Unsubscribe", "email","name","fqdn_listname"]] # should at one point add the password to be required as well! #TODO class ListSettings(FieldsetForm): diff --git a/templates/mailman-django/base.html b/templates/mailman-django/base.html index 3049df8..199dea2 100644 --- a/templates/mailman-django/base.html +++ b/templates/mailman-django/base.html @@ -46,9 +46,9 @@ {% block footer %} {% include "mailman-django/list_selector.html" %} {% if request.user.is_authenticated %} -

{% trans "Login" %}

+

{% trans "Login" %} {{request.user.username}}

{% else %} -

{% trans "Logout" %}

+

{% trans "Logout" %} {{request.user.username}}

{% endif %} {% endblock %} diff --git a/templates/mailman-django/lists/subscriptions.html b/templates/mailman-django/lists/subscriptions.html index 47afbc8..d097556 100644 --- a/templates/mailman-django/lists/subscriptions.html +++ b/templates/mailman-django/lists/subscriptions.html @@ -9,7 +9,7 @@
{% trans "Subscriptions" %}
{% if form_subscribe %} -
+ {{ form_subscribe.as_div }}
@@ -18,7 +18,7 @@ {% endif %} {% if form_unsubscribe %} -
+ {{ form_unsubscribe.as_div }}
diff --git a/views.py b/views.py index b3b857c..7c1190f 100644 --- a/views.py +++ b/views.py @@ -177,6 +177,8 @@ error = None form_subscribe = None form_unsubscribe = None + if request.POST.get('fqdn_listname', ''): + fqdn_listname = request.POST.get('fqdn_listname', '') # connect REST and catch issues getting the list try: c = Client('http://localhost:8001/3.0', API_USER, API_PASS) @@ -192,34 +194,34 @@ 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": + if request.POST.get('name', '') == "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: email = form.cleaned_data['email'] response = the_list.subscribe(address=email,real_name=form.cleaned_data.get('real_name', '')) - return render_to_response('mailman-django/lists/index.html', - {'fqdn_listname': fqdn_listname, + return render_to_response('mailman-django/lists/summary.html', + {'list': the_list, 'option':option, 'message':_("Subscribed ")+ email },context_instance=RequestContext(request)) - except Exception, e: #TODO-Exception - return HttpResponse(e) + except HTTPError, e: + return render_to_response('mailman-django/errors/generic.html', + {'error':e}, context_instance=RequestContext(request)) else: #invalid subscribe form - form_subscribe = ListSubscribe(request.POST) + form_subscribe = form form_unsubscribe = ListUnsubscribe(initial = {'fqdn_listname': fqdn_listname, 'name' : 'unsubscribe'}) - elif action == "unsubscribe": + elif request.POST.get('name', '') == "unsubscribe": form = ListUnsubscribe(request.POST) if form.is_valid(): #the form was valid so try to unsubscribe the user try: - response = the_list.unsubscribe(address=email) - return render_to_response('mailman-django/lists/index.html', - {'fqdn_listname': fqdn_listname, 'message':_("Unsubscribed ")+ email },context_instance=RequestContext(request)) - except Exception, e:#TODO-Exception - return HttpResponse(e) + response = the_list.unsubscribe(address=form.cleaned_data["email"]) + return render_to_response('mailman-django/lists/summary.html', + {'list': the_list, 'message':_("Unsubscribed ")+ email },context_instance=RequestContext(request)) + except ValueError, e: + return render_to_response('mailman-django/errors/generic.html', + {'error':e}, context_instance=RequestContext(request)) else:#invalid unsubscribe form form_subscribe = ListSubscribe(initial = {'fqdn_listname': fqdn_listname, 'option':option,