diff --git a/src/mailmanweb/forms.py b/src/mailmanweb/forms.py index e44359d..d5aae00 100644 --- a/src/mailmanweb/forms.py +++ b/src/mailmanweb/forms.py @@ -137,15 +137,17 @@ class ListSubscribe(FieldsetForm): """Form fields to join an existing list. """ - email = forms.EmailField(label = _('Your email address'), + email = forms.EmailField(label = _('Your email address'), + widget = forms.HiddenInput(), error_messages = {'required': _('Please enter an email address.'), 'invalid': _('Please enter a valid email address.')}) - display_name = forms.CharField(label=_('Your name'), required=False) + display_name = forms.CharField(label=_('Your name (optional)'), required=False) class ListUnsubscribe(FieldsetForm): """Form fields to leave an existing list. """ email = forms.EmailField(label = _('Your email address'), + widget = forms.HiddenInput(), error_messages = { 'required': _('Please enter an email address.'), 'invalid': _('Please enter a valid email address.')}) diff --git a/src/mailmanweb/static/mailmanweb/default/css/style.css b/src/mailmanweb/static/mailmanweb/default/css/style.css index dd5032d..2ee0af0 100755 --- a/src/mailmanweb/static/mailmanweb/default/css/style.css +++ b/src/mailmanweb/static/mailmanweb/default/css/style.css @@ -4,6 +4,7 @@ h1 { clear: both; margin: 20px 0; + font-weight: normal; } h1 span { font-size: 75%; @@ -11,6 +12,7 @@ } h2 { margin: 10px 0; + font-weight: normal; } .mm_canvas { @@ -68,6 +70,10 @@ .mm_logout:hover { background-position: 0px -205px; } .mm_lists:hover { background-position: 0px -276px; } +.mm_main { + clear: both; +} + .mm_subHeader { padding-top: 10px; } diff --git a/src/mailmanweb/templates/mailmanweb/base.html b/src/mailmanweb/templates/mailmanweb/base.html index 956eb2d..00c55b7 100644 --- a/src/mailmanweb/templates/mailmanweb/base.html +++ b/src/mailmanweb/templates/mailmanweb/base.html @@ -1,5 +1,4 @@ - -{% load i18n %} +{% load i18n %} @@ -22,26 +21,14 @@
- + {% if user.is_authenticated %}
Logged in as: {{ user.username }}
diff --git a/src/mailmanweb/templates/mailmanweb/lists/held_messages.html b/src/mailmanweb/templates/mailmanweb/lists/held_messages.html index 69b8a1c..ba1698b 100644 --- a/src/mailmanweb/templates/mailmanweb/lists/held_messages.html +++ b/src/mailmanweb/templates/mailmanweb/lists/held_messages.html @@ -25,10 +25,10 @@ {{ msg.reason }} {{ msg.hold_date }} - {% trans 'Accept' %} - {% trans 'Defer' %} - {% trans 'Reject' %} - {% trans 'Discard' %} + {% trans 'Accept' %} + {% trans 'Defer' %} + {% trans 'Reject' %} + {% trans 'Discard' %} diff --git a/src/mailmanweb/templates/mailmanweb/lists/mass_subscribe.html b/src/mailmanweb/templates/mailmanweb/lists/mass_subscribe.html index cda8695..ba76647 100644 --- a/src/mailmanweb/templates/mailmanweb/lists/mass_subscribe.html +++ b/src/mailmanweb/templates/mailmanweb/lists/mass_subscribe.html @@ -12,7 +12,7 @@ {{ form.as_p }}
- +
{% endblock main %} diff --git a/src/mailmanweb/templates/mailmanweb/lists/settings.html b/src/mailmanweb/templates/mailmanweb/lists/settings.html index 76b0281..115f4d2 100644 --- a/src/mailmanweb/templates/mailmanweb/lists/settings.html +++ b/src/mailmanweb/templates/mailmanweb/lists/settings.html @@ -14,7 +14,7 @@ {% if visible_section %}
{{ form.as_p }} - +
{% endif %} diff --git a/src/mailmanweb/templates/mailmanweb/lists/summary.html b/src/mailmanweb/templates/mailmanweb/lists/summary.html index e1399e5..cce023d 100644 --- a/src/mailmanweb/templates/mailmanweb/lists/summary.html +++ b/src/mailmanweb/templates/mailmanweb/lists/summary.html @@ -7,39 +7,16 @@ {% if user.is_superuser %} {% include 'mailmanweb/menu/list_nav.html' %} {% endif %} -

{{list.real_name}}

+

{{list.display_name}}

-
-
- -
-
-

{% trans "Subscribe list" %}

-
- {{subscribe_form.as_p}} - -
-
-
-
-
- -
-
-

{% trans "Unsubscribe / Leave this list" %}

-
- {{unsubscribe_form.as_p}} - -
-
-
-
-
-

{{list.settings.description }} +

{% trans 'Description' %}

+

{{list.settings.description }} +

{% trans 'Membership' %}

+
+ {{subscribe_form.as_p}} + + Unsubscribe +
{% endblock %} diff --git a/src/mailmanweb/templates/mailmanweb/login.html b/src/mailmanweb/templates/mailmanweb/login.html index eb5096d..4a26679 100644 --- a/src/mailmanweb/templates/mailmanweb/login.html +++ b/src/mailmanweb/templates/mailmanweb/login.html @@ -8,12 +8,13 @@
+

Login using BrowserID

diff --git a/src/mailmanweb/urls.py b/src/mailmanweb/urls.py index 26841e9..ded55ca 100644 --- a/src/mailmanweb/urls.py +++ b/src/mailmanweb/urls.py @@ -22,7 +22,7 @@ urlpatterns = patterns('mailmanweb.views', - (r'^$', 'user_profile'), + (r'^$', 'list_index'), # /account/ url(r'^accounts/login/$', 'user_login', name='user_login'), url(r'^accounts/logout/$', 'user_logout', name='user_logout'), @@ -45,7 +45,7 @@ name='list_summary'), url(r'^lists/(?P[^/]+)/subscribe$', 'list_subscribe', name='list_subscribe'), - url(r'^lists/(?P[^/]+)/unsubscribe$', + url(r'^lists/(?P[^/]+)/unsubscribe/(?P[^/]+)$', 'list_unsubscribe', name='list_unsubscribe'), url(r'^lists/(?P[^/]+)/subscriptions$', 'list_subscriptions', name='list_subscriptions'), @@ -53,6 +53,14 @@ 'mass_subscribe', name='mass_subscribe'), url(r'^lists/(?P[^/]+)/delete$', 'list_delete', name='list_delete'), + url(r'^lists/(?P[^/]+)/held_messages/(?P[^/]+)/accept$', 'accept_held_message', + name='accept_held_message'), + url(r'^lists/(?P[^/]+)/held_messages/(?P[^/]+)/discard$', 'discard_held_message', + name='discard_held_message'), + url(r'^lists/(?P[^/]+)/held_messages/(?P[^/]+)/defer$', 'defer_held_message', + name='defer_held_message'), + url(r'^lists/(?P[^/]+)/held_messages/(?P[^/]+)/reject$', 'reject_held_message', + name='reject_held_message'), url(r'^lists/(?P[^/]+)/held_messages$', 'list_held_messages', name='list_held_messages'), url(r'^user_settings/$', 'user_settings', kwargs={"tab": "user"}, diff --git a/src/mailmanweb/views.py b/src/mailmanweb/views.py index 04e1e3b..89daeeb 100644 --- a/src/mailmanweb/views.py +++ b/src/mailmanweb/views.py @@ -192,7 +192,6 @@ ) def list_summary(request, fqdn_listname, option=None ,template='mailmanweb/lists/summary.html'): """ - PUBLIC an entry page for each lists which allows some simple tasks per LIST """ try: @@ -200,10 +199,10 @@ except MailmanApiError: return utils.render_api_error(request) return render_to_response(template, - {'list': the_list, - 'subscribe_form': ListSubscribe(), - 'unsubscribe_form': ListUnsubscribe()}, - context_instance=RequestContext(request)) + {'list': the_list, + 'subscribe_form': ListSubscribe( + initial={'email':request.user.email}),}, + context_instance=RequestContext(request)) def list_subscribe(request, fqdn_listname): """Subscribe to a list. @@ -231,20 +230,20 @@ {'form': form, 'list': the_list,}, context_instance=RequestContext(request)) -def list_unsubscribe(request, fqdn_listname): +def list_unsubscribe(request, fqdn_listname, email): """Unsubscribe from a list. """ try: the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) except MailmanApiError: return utils.render_api_error(request) - if request.method == 'POST': - form = ListUnsubscribe(request.POST) - else: - form = ListUnsubscribe() - return render_to_response('mailmanweb/lists/unsubscribe.html', - {'form': form, 'list': the_list,}, - context_instance=RequestContext(request)) + try: + the_list.unsubscribe(email) + messages.success(request, '%s has been unsubscribed from this list.' % + email) + except ValueError, e: + messages.error(request, e) + return redirect('list_summary', the_list.fqdn_listname) def list_subscriptions(request, option=None, fqdn_listname=None, user_email = None, template = 'mailmanweb/lists/subscriptions.html', *args, **kwargs):#TODO **only kwargs ? @@ -359,6 +358,66 @@ {'list':the_list,}, context_instance=RequestContext(request)) +@user_passes_test(lambda u: u.is_superuser) +def accept_held_message(request, fqdn_listname, msg_id): + """Accepts a held message. + """ + try: + the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) + the_list.accept_message(msg_id) + except MailmanApiError: + return utils.render_api_error(request) + except HTTPError, e: + messages.error(request,e.msg) + return redirect('list_held_messages', the_list.fqdn_listname) + messages.successful(request, 'The message has been accepted.') + return redirect('list_held_messages', the_list.fqdn_listname) + +@user_passes_test(lambda u: u.is_superuser) +def discard_held_message(request, fqdn_listname, msg_id): + """Accepts a held message. + """ + try: + the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) + the_list.discard_message(msg_id) + except MailmanApiError: + return utils.render_api_error(request) + except HTTPError, e: + messages.error(request,e.msg) + return redirect('list_held_messages', the_list.fqdn_listname) + messages.successful(request, 'The message has been discarded.') + return redirect('list_held_messages', the_list.fqdn_listname) + +@user_passes_test(lambda u: u.is_superuser) +def defer_held_message(request, fqdn_listname, msg_id): + """Accepts a held message. + """ + try: + the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) + the_list.defer_message(msg_id) + except MailmanApiError: + return utils.render_api_error(request) + except HTTPError, e: + messages.error(request,e.msg) + return redirect('list_held_messages', the_list.fqdn_listname) + messages.successful(request, 'The message has been defered.') + return redirect('list_held_messages', the_list.fqdn_listname) + +@user_passes_test(lambda u: u.is_superuser) +def reject_held_message(request, fqdn_listname, msg_id): + """Accepts a held message. + """ + try: + the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) + the_list.reject_message(msg_id) + except MailmanApiError: + return utils.render_api_error(request) + except HTTPError, e: + messages.error(request,e.msg) + return redirect('list_held_messages', the_list.fqdn_listname) + messages.successful(request, 'The message has been rejected.') + return redirect('list_held_messages', the_list.fqdn_listname) + @login_required def list_settings(request, fqdn_listname=None, visible_section=None, visible_option=None, template='mailmanweb/lists/settings.html'): @@ -605,7 +664,7 @@ logger.debug(user) if user.is_active: login(request,user) - return redirect(request.GET.get('next', 'user_profile')) + return redirect(request.GET.get('next', 'list_index')) else: form = AuthenticationForm() return render_to_response(template, {'form': form,},