diff --git a/src/postorius/forms.py b/src/postorius/forms.py index da68656..e093870 100644 --- a/src/postorius/forms.py +++ b/src/postorius/forms.py @@ -587,13 +587,10 @@ layout = [["Mass subscription", "emails"]] -class UserPreferences(FieldsetForm): - """Form handling the user's global preferences. +class MembershipSettings(FieldsetForm): + """Form handling the membership settings. """ choices = ((True, _('Yes')), (False, _('No'))) - - delivery_mode_choices = (("regular", _('Regular')), ("plaintext_digests",_('Plain Text Digests')),("mime_digests",_('Mime Digests')),("summary_digests", _('Summary Digests'))) - delivery_status_choices = (("enabled", _('Enabled')),("by_user",_('Disabled'))) acknowledge_posts = forms.BooleanField( widget=forms.RadioSelect(choices=choices), required=False, @@ -611,14 +608,22 @@ required=False, label=_('Receive own postings')) delivery_mode = forms.ChoiceField( - widget = forms.Select(), - choices = delivery_mode_choices, - required = False, - label = _('Delivery mode')) - delivery_status = forms.ChoiceField( - widget = forms.Select(), + widget=forms.Select(), + error_messages={ + 'required': _("Please choose a mode.")}, required=False, - choices= delivery_status_choices, + choices=( + ("", _("Please choose")), + ("delivery_mode", "some mode...")), + label=_('Delivery mode')) + delivery_status = forms.ChoiceField( + widget=forms.Select(), + error_messages={ + 'required': _("Please choose a status.")}, + required=False, + choices=( + ("", _("Please choose")), + ("delivery_status", "some status...")), label=_('Delivery status')) class Meta: @@ -630,6 +635,7 @@ "receive_list_copy", "receive_own_postings", "delivery_mode", "delivery_status"]] + class UserNew(FieldsetForm): """ Form field to add a new user diff --git a/src/postorius/templates/postorius/user_mailmansettings.html b/src/postorius/templates/postorius/user_mailmansettings.html index accd7d0..273292b 100644 --- a/src/postorius/templates/postorius/user_mailmansettings.html +++ b/src/postorius/templates/postorius/user_mailmansettings.html @@ -12,56 +12,90 @@ {% else %}
-

{% trans "Subscription Settings" %} - {{ user }}

+

{% trans "Subscription Settings" %} - {{ user }}

- +

Mailman display name: {{ mm_user.display_name}}

+

Django email: {{ user.email }}

+

Mailman primary email: {{ mm_user.email }}

+

Valid email addresses for this account:

+ -

Global Preferences Overview

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{% trans 'Receive List Copy' %}{{ mm_user.preferences.receive_list_copy }}
{% trans 'Hide Address' %}{{ mm_user.preferences.hide_address }}
{% trans 'Preferred Language' %}{{ mm_user.preferences.preferred_language }}
{% trans 'Acknowledge Posts' %}{{ mm_user.preferences.acknowledge_posts }}
{% trans 'Delivery Mode' %}{{ mm_user.preferences.delivery_mode }}
{% trans 'Receive Own Postings' %}{{ mm_user.preferences.receive_own_postings }}
{% trans 'Delivery Status' %}{{ mm_user.preferences.delivery_status }}
+

WARNING: This page is currently a mockup and +anything below this line may not work

+

Preferences:

+

preferences: {{ mm_user.preferences }} +

user: {{ mm_user }} +

tko +

memberships: {{ membership_lists }} + {% for pref in mm_user.preferences %} +

  • {{ pref }}
  • + {% endfor %} + +

    Sample output: not real

    + -

    Global Preferences Form

    - +

    Prefs form

    {% csrf_token %} {{ settingsform.as_p }}
    - +

    List Preferences Overview

    +

    Sample output: not real

    + +
    {% csrf_token %} + + + + + + + + + + + + + + + + + + {% for preference in mm_user.preferences %} + {% endfor %} + + + + + + + + + + + +
    {% trans "Setting" %}{% trans "Description" %}{% trans "Set all" %}list1@example.comkumquat@example.comstarfruit@example.com
    {% trans "Mail delivery" %} ({{ preference }})Set this option to Enabled to receive +messages posted + to this mailing list. Set it to Disabled if you want + to stay subscribed, but don't want mail delivered to you for a + while (e.g. you're going on vacation). If you disable mail + delivery, don't forget to re-enable it when you come back; it + will not be automatically re-enabled."
    {% trans "Per-Email subscriptions" %}
    anna@example.com
    +
    {% endif %} {% endblock main %} -~ +~ diff --git a/src/postorius/views/user.py b/src/postorius/views/user.py index b6d2d5e..a5acb5c 100644 --- a/src/postorius/views/user.py +++ b/src/postorius/views/user.py @@ -53,23 +53,7 @@ @method_decorator(login_required) def post(self, request): - try: - mm_user = MailmanUser.objects.get(address=request.user.email) - userprefs_form = UserPreferences(request.POST) - if userprefs_form.is_valid(): - user_preferences = mm_user.preferences - for key in userprefs_form.fields.keys(): - user_preferences[key] = userprefs_form.cleaned_data[key] - user_preferences.save() - messages.success(request, 'Your preferences have been updated.') - else: - messages.error(request, 'Something went wrong.') - except MailmanApiError: - return utils.render_api_error(request) - except HTTPError, e: - messages.error(request, e.msg) - return redirect("user_mailmansettings") - + raise NotImplementedError @method_decorator(login_required) def get(self, request): @@ -85,12 +69,13 @@ 'postorius/user_mailmansettings.html', {'nolists': 'true'}, context_instance=RequestContext(request)) - settingsform = UserPreferences(initial = mm_user.preferences) + settingsform = MembershipSettings() return render_to_response('postorius/user_mailmansettings.html', {'mm_user': mm_user, 'settingsform': settingsform}, context_instance=RequestContext(request)) + class UserSummaryView(MailmanUserView): """Shows a summary of a user. """