Merge lp:~stylistica/postorius/user_preferences into lp:postorius

Proposed by Sneha Priscilla
Status: Merged
Merged at revision: 150
Proposed branch: lp:~stylistica/postorius/user_preferences
Merge into: lp:postorius
Diff against target: 239 lines (+73/-98)
3 files modified
src/postorius/forms.py (+11/-17)
src/postorius/templates/postorius/user_mailmansettings.html (+44/-78)
src/postorius/views/user.py (+18/-3)
To merge this branch: bzr merge lp:~stylistica/postorius/user_preferences
Reviewer Review Type Date Requested Status
Terri Approve
Florian Fuchs Pending
Review via email: mp+179274@code.launchpad.net

Description of the change

I've added a form for the user to view/update their mailing list preferences on a global level.

For these changes to work, the following branches need to be merged into Mailman and Mailman.client respectively:

https://code.launchpad.net/~stylistica/mailman/user_preferences
https://code.launchpad.net/~stylistica/mailman.client/user_preferences

To post a comment you must log in.
Revision history for this message
Florian Fuchs (flo-fuchs) wrote :

Hi Sneha,

thanks for the merge request!

The new form, as well as the template and view code look pretty good!

The only thing left to do in my view is some style-related cleanup. So if you want to make it perfect I'd check for PEP8 inconsistencies (long lines, missing/unnecessary spaces etc.). Also, there seem to be some lines containing tabs instead of spaces.

Other than that the changes are good!
Thanks again.

Florian

Revision history for this message
Terri (terriko) wrote :

We're looking for some "easy" bugs to fix at the GHC Open Source Day, so I'm actually going to merge this as-is and then let our new contributors find the style problems as simple first commits. (I know, I know, this isn't how it's supposed to be done, but it'll be fun!)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/postorius/forms.py'
2--- src/postorius/forms.py 2013-03-21 18:43:28 +0000
3+++ src/postorius/forms.py 2013-08-08 20:50:48 +0000
4@@ -587,10 +587,13 @@
5 layout = [["Mass subscription", "emails"]]
6
7
8-class MembershipSettings(FieldsetForm):
9- """Form handling the membership settings.
10+class UserPreferences(FieldsetForm):
11+ """Form handling the user's global preferences.
12 """
13 choices = ((True, _('Yes')), (False, _('No')))
14+
15+ delivery_mode_choices = (("regular", _('Regular')), ("plaintext_digests",_('Plain Text Digests')),("mime_digests",_('Mime Digests')),("summary_digests", _('Summary Digests')))
16+ delivery_status_choices = (("enabled", _('Enabled')),("by_user",_('Disabled')))
17 acknowledge_posts = forms.BooleanField(
18 widget=forms.RadioSelect(choices=choices),
19 required=False,
20@@ -608,22 +611,14 @@
21 required=False,
22 label=_('Receive own postings'))
23 delivery_mode = forms.ChoiceField(
24- widget=forms.Select(),
25- error_messages={
26- 'required': _("Please choose a mode.")},
27- required=False,
28- choices=(
29- ("", _("Please choose")),
30- ("delivery_mode", "some mode...")),
31- label=_('Delivery mode'))
32+ widget = forms.Select(),
33+ choices = delivery_mode_choices,
34+ required = False,
35+ label = _('Delivery mode'))
36 delivery_status = forms.ChoiceField(
37- widget=forms.Select(),
38- error_messages={
39- 'required': _("Please choose a status.")},
40+ widget = forms.Select(),
41 required=False,
42- choices=(
43- ("", _("Please choose")),
44- ("delivery_status", "some status...")),
45+ choices= delivery_status_choices,
46 label=_('Delivery status'))
47
48 class Meta:
49@@ -635,7 +630,6 @@
50 "receive_list_copy", "receive_own_postings",
51 "delivery_mode", "delivery_status"]]
52
53-
54 class UserNew(FieldsetForm):
55 """
56 Form field to add a new user
57
58=== modified file 'src/postorius/templates/postorius/user_mailmansettings.html'
59--- src/postorius/templates/postorius/user_mailmansettings.html 2013-06-30 22:39:39 +0000
60+++ src/postorius/templates/postorius/user_mailmansettings.html 2013-08-08 20:50:48 +0000
61@@ -12,90 +12,56 @@
62 {% else %}
63
64 <div class="mm_subHeader">
65- <h1>{% trans "Subscription Settings" %} <span>- {{ user }}</span></h1>
66+ <h2>{% trans "Subscription Settings" %} <span>- {{ user }}</span></h2>
67 </div>
68
69- <p><strong>Mailman display name:</strong> {{ mm_user.display_name}}</p>
70- <p><strong>Django email:</strong> {{ user.email }}</p>
71- <p><strong>Mailman primary email:</strong> {{ mm_user.email }}</p>
72- <h2>Valid email addresses for this account:</h2>
73- <ul>
74-<!-- ADDRESSES/EMAIL@/MEMBERSHIPS -->
75- {% for address in mm_user.addresses %}
76- <li>{{ address }}</li>
77- {% endfor %}
78- </ul>
79-
80- <h2 style="color: red">WARNING: This page is currently a mockup and
81-anything below this line may not work</h2>
82-
83- <h2>Preferences:</h2>
84- <p>preferences: {{ mm_user.preferences }}
85- <p>user: {{ mm_user }}
86- <p>tko
87- <p>memberships: {{ membership_lists }}
88- {% for pref in mm_user.preferences %}
89- <li>{{ pref }}</li>
90- {% endfor %}
91-
92- <p><em class="errorlist">Sample output: not real</em></p>
93- <ul>
94- <li>list1@example.com [<a href="#">listinfo</a>]
95- [<a href="#">settings</a>]</li>
96- <li>kumquat@example.com [<a href="#">listinfo</a>]
97- [<a href="#">settings</a>]</li>
98- <li>starfruit@example.com [<a href="#">listinfo</a>]
99- [<a href="#">settings</a>]</li>
100- </ul>
101-
102- <h2>Prefs form</h2>
103+
104+
105+<h2> Global Preferences Overview </h2>
106+<!-- Table displaying the user's global Mailman preferencesc, may be removed-->
107+<table class="table table-bordered table-striped mm_userData">
108+ <tbody>
109+ <tr>
110+ <td>{% trans 'Receive List Copy' %}</td>
111+ <td>{{ mm_user.preferences.receive_list_copy }}</td>
112+ </tr>
113+ <tr>
114+ <td>{% trans 'Hide Address' %}</td>
115+ <td>{{ mm_user.preferences.hide_address }}</td>
116+ </tr>
117+ <tr>
118+ <td>{% trans 'Preferred Language' %}</td>
119+ <td>{{ mm_user.preferences.preferred_language }}</td>
120+ </tr>
121+ <tr>
122+ <td>{% trans 'Acknowledge Posts' %}</td>
123+ <td>{{ mm_user.preferences.acknowledge_posts }}</td>
124+ </tr>
125+ <tr>
126+ <td>{% trans 'Delivery Mode' %}</td>
127+ <td>{{ mm_user.preferences.delivery_mode }}</td>
128+ </tr>
129+ <tr>
130+ <td>{% trans 'Receive Own Postings' %}</td>
131+ <td>{{ mm_user.preferences.receive_own_postings }}</td>
132+ </tr>
133+ <tr>
134+ <td>{% trans 'Delivery Status' %}</td>
135+ <td>{{ mm_user.preferences.delivery_status }}</td>
136+ </tr>
137+
138+ </tbody>
139+ </table>
140+
141+
142+ <h2>Global Preferences Form</h2>
143+ <!-- Form to modify the user's global Mailman preferences -->
144 <form action="{% url 'user_mailmansettings' %}" method="post" class="well"> {% csrf_token %}
145 {{ settingsform.as_p }}
146 <button class="btn btn-success" type="submit">{% trans "Save" %}</button>
147 </form>
148
149- <h2>List Preferences Overview</h2>
150- <p><em class="errorlist">Sample output: not real</em></p>
151- <input id="btnHide" type="button" value="{% trans "Hide Descriptions" %}"/>
152- <form action="#"> {% csrf_token %}
153- <table class="table table-bordered table-striped">
154- <tr>
155- <th>{% trans "Setting" %}</th>
156- <th>{% trans "Description" %}</th>
157- <th>{% trans "Set all" %}</th>
158- <th class="rotate">list1@example.com</th>
159- <th class="rotate">kumquat@example.com</th>
160- <th class="rotate">starfruit@example.com</th>
161- </tr>
162- <tr>
163- <th>{% trans "Mail delivery" %} ({{ preference }})</th>
164- <td>Set this option to <em>Enabled</em> to receive
165-messages posted
166- to this mailing list. Set it to <em>Disabled</em> if you want
167- to stay subscribed, but don't want mail delivered to you for a
168- while (e.g. you're going on vacation). If you disable mail
169- delivery, don't forget to re-enable it when you come back; it
170- will not be automatically re-enabled." </td>
171- <td><input type="checkbox" /></td>
172- <td><input type="checkbox" /></td>
173- <td><input type="checkbox" /></td>
174- <td><input type="checkbox" /></td>
175- </tr>
176- {% for preference in mm_user.preferences %}
177- {% endfor %}
178- <tr>
179- <th colspan="6">{% trans "Per-Email subscriptions" %}</th>
180- </tr>
181- <tr>
182- <th colspan="2">anna@example.com</th>
183- <td><input type="checkbox" /></td>
184- <td><input type="checkbox" /></td>
185- <td><input type="checkbox" /></td>
186- <td><input type="checkbox" /></td>
187- <tr>
188- </tr>
189- </table>
190- </form>
191+
192 {% endif %}
193 {% endblock main %}
194-~
195+~
196
197=== modified file 'src/postorius/views/user.py'
198--- src/postorius/views/user.py 2013-07-11 14:35:41 +0000
199+++ src/postorius/views/user.py 2013-08-08 20:50:48 +0000
200@@ -53,7 +53,23 @@
201
202 @method_decorator(login_required)
203 def post(self, request):
204- raise NotImplementedError
205+ try:
206+ mm_user = MailmanUser.objects.get(address=request.user.email)
207+ userprefs_form = UserPreferences(request.POST)
208+ if userprefs_form.is_valid():
209+ user_preferences = mm_user.preferences
210+ for key in userprefs_form.fields.keys():
211+ user_preferences[key] = userprefs_form.cleaned_data[key]
212+ user_preferences.save()
213+ messages.success(request, 'Your preferences have been updated.')
214+ else:
215+ messages.error(request, 'Something went wrong.')
216+ except MailmanApiError:
217+ return utils.render_api_error(request)
218+ except HTTPError, e:
219+ messages.error(request, e.msg)
220+ return redirect("user_mailmansettings")
221+
222
223 @method_decorator(login_required)
224 def get(self, request):
225@@ -69,13 +85,12 @@
226 'postorius/user_mailmansettings.html',
227 {'nolists': 'true'},
228 context_instance=RequestContext(request))
229- settingsform = MembershipSettings()
230+ settingsform = UserPreferences(initial = mm_user.preferences)
231 return render_to_response('postorius/user_mailmansettings.html',
232 {'mm_user': mm_user,
233 'settingsform': settingsform},
234 context_instance=RequestContext(request))
235
236-
237 class UserSummaryView(MailmanUserView):
238 """Shows a summary of a user.
239 """

Subscribers

People subscribed via source and target branches