diff --git a/src/postorius/templates/postorius/lists/summary.html b/src/postorius/templates/postorius/lists/summary.html index 23343dc..bac1848 100644 --- a/src/postorius/templates/postorius/lists/summary.html +++ b/src/postorius/templates/postorius/lists/summary.html @@ -42,6 +42,12 @@ {% trans 'Unsubscribe' %} {{ subscribed_address }}

+ {% url 'user_list_options' list.list_id as user_list_options_url %} + {% blocktrans %} +

+ You can manage your subscription here +

+ {% endblocktrans %} {% else %}

{% trans 'Subscribe to this list' %}

diff --git a/src/postorius/templates/postorius/user/list_options.html b/src/postorius/templates/postorius/user/list_options.html new file mode 100644 index 0000000..6666c23 --- /dev/null +++ b/src/postorius/templates/postorius/user/list_options.html @@ -0,0 +1,17 @@ +{% extends postorius_base_template %} +{% load i18n %} +{% load nav_helpers %} +{% load bootstrap_tags %} + +{% block subtitle %} +{% trans 'Member options' %} | {{ list.list_fqdn }} +{% endblock %} + +{% block main %} +

{% trans 'Subscription options for' %} {{ list.fqdn_listname }}

+
+ + {% render_form_horizontal form 3 8 'Save changes' %} + +
+{% endblock main %} diff --git a/src/postorius/urls.py b/src/postorius/urls.py index 68c8f17..fe32772 100644 --- a/src/postorius/urls.py +++ b/src/postorius/urls.py @@ -102,6 +102,8 @@ url(r'^accounts/mailmansettings/$', UserMailmanSettingsView.as_view(), name='user_mailmansettings'), + url(r'^accounts/list-options/(?P[^/]+)/$', user_list_options, + name='user_list_options'), # /domains/ url(r'^domains/$', 'domain_index', name='domain_index'), url(r'^domains/new/$', 'domain_new', name='domain_new'), diff --git a/src/postorius/views/user.py b/src/postorius/views/user.py index 3ea293f..e64c1e8 100644 --- a/src/postorius/views/user.py +++ b/src/postorius/views/user.py @@ -25,6 +25,8 @@ from django.utils.decorators import method_decorator from django.utils.translation import gettext as _ from django.views.generic import TemplateView +from django.http import Http404 + try: from urllib2 import HTTPError except ImportError: @@ -125,6 +127,33 @@ context_instance=RequestContext(request)) +@login_required +def user_list_options(request, list_id): + mlist = List.objects.get_or_404(fqdn_listname=list_id) + mm_user = MailmanUser.objects.get(address=request.user.email) + subscription = None + for s in mm_user.subscriptions: + if s.role == 'member' and s.list_id == list_id: + subscription = s + break + if not subscription: + raise Http404(_('Subscription does not exist')) + preferences = subscription.preferences + if request.method == 'POST': + form = UserPreferences(request.POST) + if form.is_valid(): + for key in form.cleaned_data.keys(): + preferences[key] = form.cleaned_data[key] + preferences.save() + messages.success(request, _('Your preferences have been updated.')) + else: + messages.error(request, _('Something went wrong.')) + else: + form = UserPreferences(initial=subscription.preferences) + return render_to_response('postorius/user/list_options.html', + {'form': form, 'list': mlist,}, context_instance=RequestContext(request)) + + class UserSubscriptionPreferencesView(MailmanUserView): """The logged-in user's subscription-based Mailman Preferences."""