Merge lp:~raj-abhilash1/postorius/bug_1201150 into lp:postorius
- bug_1201150
- Merge into trunk
Proposed by
Abhilash Raj
Status: | Merged |
---|---|
Merged at revision: | 193 |
Proposed branch: | lp:~raj-abhilash1/postorius/bug_1201150 |
Merge into: | lp:postorius |
Diff against target: |
748 lines (+115/-111) (has conflicts) 13 files modified
setup.py (+2/-1) src/postorius/auth/decorators.py (+5/-5) src/postorius/templates/postorius/lists/confirm_delete.html (+1/-1) src/postorius/templates/postorius/lists/confirm_remove_role.html (+1/-1) src/postorius/templates/postorius/lists/index.html (+1/-1) src/postorius/templates/postorius/lists/settings.html (+2/-2) src/postorius/templates/postorius/lists/summary.html (+5/-1) src/postorius/templates/postorius/menu/list_nav.html (+15/-15) src/postorius/tests/test_auth_decorators.py (+25/-25) src/postorius/urls.py (+1/-1) src/postorius/views/generic.py (+4/-4) src/postorius/views/list.py (+53/-53) src/postorius/views/settings.py (+0/-1) Text conflict in src/postorius/templates/postorius/lists/summary.html |
To merge this branch: | bzr merge lp:~raj-abhilash1/postorius/bug_1201150 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mailman Coders | Pending | ||
Review via email: mp+246850@code.launchpad.net |
Commit message
Description of the change
Fix #1201150
Add django-nose as a testing requirement
To post a comment you must log in.
Revision history for this message
Florian Fuchs (flo-fuchs) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'setup.py' |
2 | --- setup.py 2014-04-22 14:35:55 +0000 |
3 | +++ setup.py 2015-01-18 19:24:47 +0000 |
4 | @@ -37,5 +37,6 @@ |
5 | include_package_data = True, |
6 | install_requires = ['django>=1.4', |
7 | 'django-social-auth>=0.7.8', |
8 | - 'mailmanclient', ] |
9 | + 'mailmanclient', |
10 | + 'django_nose',] |
11 | ) |
12 | |
13 | === modified file 'src/postorius/auth/decorators.py' |
14 | --- src/postorius/auth/decorators.py 2014-03-15 21:36:39 +0000 |
15 | +++ src/postorius/auth/decorators.py 2015-01-18 19:24:47 +0000 |
16 | @@ -51,14 +51,14 @@ |
17 | """ |
18 | def wrapper(*args, **kwargs): |
19 | user = args[0].user |
20 | - fqdn_listname = kwargs['fqdn_listname'] |
21 | + list_id = kwargs['list_id'] |
22 | if not user.is_authenticated(): |
23 | raise PermissionDenied |
24 | if user.is_superuser: |
25 | return fn(*args, **kwargs) |
26 | if getattr(user, 'is_list_owner', None): |
27 | return fn(*args, **kwargs) |
28 | - mlist = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
29 | + mlist = List.objects.get_or_404(fqdn_listname=list_id) |
30 | if user.email not in mlist.owners: |
31 | raise PermissionDenied |
32 | else: |
33 | @@ -69,12 +69,12 @@ |
34 | |
35 | def list_moderator_required(fn): |
36 | """Check if the logged in user is a moderator of the given list. |
37 | - Assumes that the request object is the first arg and that fqdn_listname |
38 | + Assumes that the request object is the first arg and that list_id |
39 | is present in kwargs. |
40 | """ |
41 | def wrapper(*args, **kwargs): |
42 | user = args[0].user |
43 | - fqdn_listname = kwargs['fqdn_listname'] |
44 | + list_id = kwargs['list_id'] |
45 | if not user.is_authenticated(): |
46 | raise PermissionDenied |
47 | if user.is_superuser: |
48 | @@ -83,7 +83,7 @@ |
49 | return fn(*args, **kwargs) |
50 | if getattr(user, 'is_list_moderator', None): |
51 | return fn(*args, **kwargs) |
52 | - mlist = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
53 | + mlist = List.objects.get_or_404(fqdn_listname=list_id) |
54 | if user.email not in mlist.moderators and \ |
55 | user.email not in mlist.owners: |
56 | raise PermissionDenied |
57 | |
58 | === modified file 'src/postorius/templates/postorius/lists/confirm_delete.html' |
59 | --- src/postorius/templates/postorius/lists/confirm_delete.html 2015-01-17 17:23:59 +0000 |
60 | +++ src/postorius/templates/postorius/lists/confirm_delete.html 2015-01-18 19:24:47 +0000 |
61 | @@ -10,6 +10,6 @@ |
62 | <p>{% trans "All settings and membership data will be lost!" %}</p> |
63 | <form action="{{submit_url}}" method="post"> {% csrf_token %} |
64 | <button class="btn btn-danger" type="submit">{% trans "Delete" %} {{ list.fqdn_listname }}</button> |
65 | - <a class="btn" href="{% url 'list_summary' fqdn_listname=list.fqdn_listname %}">{% trans "Cancel" %}</a> |
66 | + <a class="btn" href="{% url 'list_summary' list_id=list.list_id %}">{% trans "Cancel" %}</a> |
67 | </form> |
68 | {% endblock main %} |
69 | |
70 | === modified file 'src/postorius/templates/postorius/lists/confirm_remove_role.html' |
71 | --- src/postorius/templates/postorius/lists/confirm_remove_role.html 2014-04-15 19:12:27 +0000 |
72 | +++ src/postorius/templates/postorius/lists/confirm_remove_role.html 2015-01-18 19:24:47 +0000 |
73 | @@ -6,7 +6,7 @@ |
74 | {% block main %} |
75 | <h1>{% trans 'Confirm Remove Role' %}</h1> |
76 | <p>{% trans "Are you sure you want to remove?" %}</p> |
77 | - <form method="post" action="{% url 'remove_role' fqdn_listname role address %}"> |
78 | + <form method="post" action="{% url 'remove_role' list_id role address %}"> |
79 | {% csrf_token %} |
80 | <button class="btn btn-danger" type="submit">{% trans "Remove " %}{{ address }}</button> |
81 | <a class="btn" href="{% url 'list_members' fqdn_listname %}">{% trans "Cancel" %}</a> |
82 | |
83 | === modified file 'src/postorius/templates/postorius/lists/index.html' |
84 | --- src/postorius/templates/postorius/lists/index.html 2014-11-03 19:40:41 +0000 |
85 | +++ src/postorius/templates/postorius/lists/index.html 2015-01-18 19:24:47 +0000 |
86 | @@ -29,7 +29,7 @@ |
87 | {% for list in lists %} |
88 | <tr> |
89 | <td> |
90 | - <a href="{% url 'list_summary' fqdn_listname=list.fqdn_listname %}">{{ list.display_name }}</a> |
91 | + <a href="{% url 'list_summary' list_id=list.list_id %}">{{ list.display_name }}</a> |
92 | </td> |
93 | <td>{{ list.fqdn_listname }}</td> |
94 | <td>{{ list.settings.description }}</td> |
95 | |
96 | === modified file 'src/postorius/templates/postorius/lists/settings.html' |
97 | --- src/postorius/templates/postorius/lists/settings.html 2015-01-17 17:23:59 +0000 |
98 | +++ src/postorius/templates/postorius/lists/settings.html 2015-01-18 19:24:47 +0000 |
99 | @@ -8,14 +8,14 @@ |
100 | {% list_nav 'list_settings' 'Settings' %} |
101 | <ul class="nav nav-tabs"> |
102 | {% for section in form_sections %} |
103 | - <li {% if section.0 == visible_section %}class="active"{% endif %}><a href="{% url 'list_settings' fqdn_listname=list.fqdn_listname visible_section=section.0 visible_option=None %}">{{section.0}}</a></li> |
104 | + <li {% if section.0 == visible_section %}class="active"{% endif %}><a href="{% url 'list_settings' list_id=list.list_id visible_section=section.0 visible_option=None %}">{{section.0}}</a></li> |
105 | {% endfor %} |
106 | </ul> |
107 | |
108 | {% if visible_section %} |
109 | |
110 | <table class="well"> |
111 | - <form class="well" action="{% url 'list_settings' fqdn_listname=list.fqdn_listname visible_section=visible_section visible_option=visible_option %}" method="post" class="list_settings"> {% csrf_token %} |
112 | + <form class="well" action="{% url 'list_settings' list_id=list.list_id visible_section=visible_section visible_option=visible_option %}" method="post" class="list_settings"> {% csrf_token %} |
113 | {% for field in form %} |
114 | <tr><td> |
115 | {{ field.errors }} |
116 | |
117 | === modified file 'src/postorius/templates/postorius/lists/summary.html' |
118 | --- src/postorius/templates/postorius/lists/summary.html 2015-01-09 15:22:37 +0000 |
119 | +++ src/postorius/templates/postorius/lists/summary.html 2015-01-18 19:24:47 +0000 |
120 | @@ -17,10 +17,14 @@ |
121 | |
122 | {% if user.is_authenticated %} |
123 | {% if userSubscribed %} |
124 | +<<<<<<< TREE |
125 | <a href="{% url 'list_unsubscribe' list.fqdn_listname user.email %}" class="btn btn-danger">{% trans "Unsubscribe" %}</a> |
126 | +======= |
127 | + <a href="{% url 'list_unsubscribe' list.user_id user.email %}" class="btn btn-danger">Unsubscribe</a> |
128 | +>>>>>>> MERGE-SOURCE |
129 | {% else %} |
130 | <h2>{% trans 'Subscribe to this list' %}</h2> |
131 | - <form action="{% url 'list_subscribe' list.fqdn_listname %}" method="post" class="list_subscribe"> {% csrf_token %} |
132 | + <form action="{% url 'list_subscribe' list.list_id %}" method="post" class="list_subscribe"> {% csrf_token %} |
133 | {{subscribe_form.as_p}} |
134 | <input class="btn btn-success" type="submit" value="{% trans 'Subscribe' %}" /> |
135 | </form> |
136 | |
137 | === modified file 'src/postorius/templates/postorius/menu/list_nav.html' |
138 | --- src/postorius/templates/postorius/menu/list_nav.html 2015-01-17 17:23:59 +0000 |
139 | +++ src/postorius/templates/postorius/menu/list_nav.html 2015-01-18 19:24:47 +0000 |
140 | @@ -5,21 +5,21 @@ |
141 | <span class="mm_context"><a href="{% url 'list_index' %}">{% trans 'Mailing Lists' %}</a> » {{ list.fqdn_listname }} » {% trans title %}</span> |
142 | {% if user|lower != 'anonymoususer' %} |
143 | <ul class="mm_nav"> |
144 | - <li class="mm_nav_item"><a class="{% nav_active_class current 'list_summary' %}" href="{% url 'list_summary' list.fqdn_listname %}">{% trans "Info" %}</a></li> |
145 | - {% if user.is_superuser or user.is_list_owner %} |
146 | - <li class="mm_nav_item"><a class="{% nav_active_class current 'list_members' %}" href="{% url 'list_members' list.fqdn_listname %}">{% trans "Members" %}</a></li> |
147 | - {% endif %} |
148 | - {% if user.is_superuser or user.is_list_moderator %} |
149 | - <li class="mm_nav_item"><a class="{% nav_active_class current 'list_held_messages' %}" href="{% url 'list_held_messages' list.fqdn_listname %}">{% trans "Held Messages" %}</a></li> |
150 | - {% endif %} |
151 | - {% if user.is_superuser or user.is_list_owner %} |
152 | - <li class="mm_nav_item"><a class="{% nav_active_class current 'list_settings' %}" href="{% url 'list_settings' list.fqdn_listname %}">{% trans "Settings" %}</a></li> |
153 | - {% endif %} |
154 | - {% if user.is_superuser or user.is_list_moderator %} |
155 | - <li class="mm_nav_item"><a class="{% nav_active_class current 'mass_subscribe' %}" href="{% url 'mass_subscribe' list.fqdn_listname %}">{% trans "Mass Subscribe" %}</a></li> |
156 | - {% endif %} |
157 | - {% if user.is_superuser or user.is_list_owner %} |
158 | - <li class="mm_nav_item"><a class="{% nav_active_class current 'list_delete' %}" href="{% url 'list_delete' list.fqdn_listname %}">{% trans "Delete List" %}</a></li> |
159 | + <li class="mm_nav_item"><a class="{% nav_active_class current 'list_summary' %}" href="{% url 'list_summary' list.list_id %}">{% trans "Info" %}</a></li> |
160 | + {% if user.is_superuser or user.is_list_owner %} |
161 | + <li class="mm_nav_item"><a class="{% nav_active_class current 'list_members' %}" href="{% url 'list_members' list.list_id %}">{% trans "Members" %}</a></li> |
162 | + {% endif %} |
163 | + {% if user.is_superuser or user.is_list_moderator %} |
164 | + <li class="mm_nav_item"><a class="{% nav_active_class current 'list_held_messages' %}" href="{% url 'list_held_messages' list.list_id %}">{% trans "Held Messages" %}</a></li> |
165 | + {% endif %} |
166 | + {% if user.is_superuser or user.is_list_owner %} |
167 | + <li class="mm_nav_item"><a class="{% nav_active_class current 'list_settings' %}" href="{% url 'list_settings' list.list_id %}">{% trans "Settings" %}</a></li> |
168 | + {% endif %} |
169 | + {% if user.is_superuser or user.is_list_moderator %} |
170 | + <li class="mm_nav_item"><a class="{% nav_active_class current 'mass_subscribe' %}" href="{% url 'mass_subscribe' list.list_id %}">{% trans "Mass Subscribe" %}</a></li> |
171 | + {% endif %} |
172 | + {% if user.is_superuser or user.is_list_owner %} |
173 | + <li class="mm_nav_item"><a class="{% nav_active_class current 'list_delete' %}" href="{% url 'list_delete' list.list_id %}">{% trans "Delete List" %}</a></li> |
174 | {% endif %} |
175 | </ul> |
176 | {% endif %} |
177 | |
178 | === modified file 'src/postorius/tests/test_auth_decorators.py' |
179 | --- src/postorius/tests/test_auth_decorators.py 2014-03-15 21:36:39 +0000 |
180 | +++ src/postorius/tests/test_auth_decorators.py 2015-01-18 19:24:47 +0000 |
181 | @@ -30,12 +30,12 @@ |
182 | |
183 | |
184 | @list_owner_required |
185 | -def dummy_function(request, fqdn_listname): |
186 | +def dummy_function(request, list_id): |
187 | return True |
188 | |
189 | |
190 | @list_moderator_required |
191 | -def dummy_function_mod_req(request, fqdn_listname): |
192 | +def dummy_function_mod_req(request, list_id): |
193 | return True |
194 | |
195 | |
196 | @@ -47,7 +47,7 @@ |
197 | from postorius.tests.utils import create_mock_list |
198 | self.request_factory = RequestFactory() |
199 | # create a mock list with members |
200 | - list_name = 'foolist@example.org' |
201 | + list_name = 'foolist.example.org' |
202 | list_id = 'foolist.example.org' |
203 | self.mock_list = create_mock_list(dict( |
204 | fqdn_listname=list_name, |
205 | @@ -57,22 +57,22 @@ |
206 | def test_not_authenticated(self, mock_get_list): |
207 | """Should raise PermissionDenied if user is not authenticated.""" |
208 | mock_get_list.return_value = self.mock_list |
209 | - request = self.request_factory.get('/lists/foolist@example.org/' |
210 | + request = self.request_factory.get('/lists/foolist.example.org/' |
211 | 'settings/') |
212 | request.user = AnonymousUser() |
213 | self.assertRaises(PermissionDenied, dummy_function, request, |
214 | - fqdn_listname='foolist@example.org') |
215 | + list_id='foolist.example.org') |
216 | |
217 | @patch.object(Client, 'get_list') |
218 | def test_superuser(self, mock_get_list): |
219 | """Should call the dummy method, if user is superuser.""" |
220 | mock_get_list.return_value = self.mock_list |
221 | - request = self.request_factory.get('/lists/foolist@example.org/' |
222 | + request = self.request_factory.get('/lists/foolist.example.org/' |
223 | 'settings/') |
224 | request.user = User.objects.create_superuser('su1', 'su@sodo.org', |
225 | 'pwd') |
226 | return_value = dummy_function(request, |
227 | - fqdn_listname='foolist@example.org') |
228 | + list_id='foolist.example.org') |
229 | self.assertEqual(return_value, True) |
230 | |
231 | @patch.object(Client, 'get_list') |
232 | @@ -82,12 +82,12 @@ |
233 | self.mock_list.owners = ['geddy@rush.it'] |
234 | mock_get_list.return_value = self.mock_list |
235 | # prepare request |
236 | - request = self.request_factory.get('/lists/foolist@example.org/' |
237 | + request = self.request_factory.get('/lists/foolist.example.org/' |
238 | 'settings/') |
239 | request.user = User.objects.create_user('les c', 'les@primus.org', |
240 | 'pwd') |
241 | self.assertRaises(PermissionDenied, dummy_function, request, |
242 | - fqdn_listname='foolist@example.org') |
243 | + list_id='foolist.example.org') |
244 | |
245 | @patch.object(Client, 'get_list') |
246 | def test_list_owner(self, mock_get_list): |
247 | @@ -96,12 +96,12 @@ |
248 | self.mock_list.owners = ['les@primus.org'] |
249 | mock_get_list.return_value = self.mock_list |
250 | # prepare request |
251 | - request = self.request_factory.get('/lists/foolist@example.org/' |
252 | + request = self.request_factory.get('/lists/foolist.example.org/' |
253 | 'settings/') |
254 | request.user = User.objects.create_user('les cl', 'les@primus.org', |
255 | 'pwd') |
256 | return_value = dummy_function(request, |
257 | - fqdn_listname='foolist@example.org') |
258 | + list_id='foolist.example.org') |
259 | self.assertEqual(return_value, True) |
260 | |
261 | |
262 | @@ -113,7 +113,7 @@ |
263 | from postorius.tests.utils import create_mock_list |
264 | self.request_factory = RequestFactory() |
265 | # create a mock list with members |
266 | - list_name = 'foolist@example.org' |
267 | + list_name = 'foolist.example.org' |
268 | list_id = 'foolist.example.org' |
269 | self.mock_list = create_mock_list(dict( |
270 | fqdn_listname=list_name, |
271 | @@ -123,23 +123,23 @@ |
272 | def test_not_authenticated(self, mock_get_list): |
273 | """Should raise PermissionDenied if user is not authenticated.""" |
274 | mock_get_list.return_value = self.mock_list |
275 | - request = self.request_factory.get('/lists/foolist@example.org/' |
276 | + request = self.request_factory.get('/lists/foolist.example.org/' |
277 | 'settings/') |
278 | request.user = AnonymousUser() |
279 | self.assertRaises(PermissionDenied, dummy_function_mod_req, request, |
280 | - fqdn_listname='foolist@example.org') |
281 | + list_id='foolist.example.org') |
282 | |
283 | @patch.object(Client, 'get_list') |
284 | def test_superuser(self, mock_get_list): |
285 | """Should call the dummy method, if user is superuser.""" |
286 | mock_get_list.return_value = self.mock_list |
287 | - request = self.request_factory.get('/lists/foolist@example.org/' |
288 | + request = self.request_factory.get('/lists/foolist.example.org/' |
289 | 'settings/') |
290 | request.user = User.objects.create_superuser('su2', 'su@sodo.org', |
291 | 'pwd') |
292 | return_value = dummy_function_mod_req(request, |
293 | - fqdn_listname= |
294 | - 'foolist@example.org') |
295 | + list_id= |
296 | + 'foolist.example.org') |
297 | self.assertEqual(return_value, True) |
298 | |
299 | @patch.object(Client, 'get_list') |
300 | @@ -149,12 +149,12 @@ |
301 | self.mock_list.moderators = ['geddy@rush.it'] |
302 | mock_get_list.return_value = self.mock_list |
303 | # prepare request |
304 | - request = self.request_factory.get('/lists/foolist@example.org/' |
305 | + request = self.request_factory.get('/lists/foolist.example.org/' |
306 | 'settings/') |
307 | request.user = User.objects.create_user('les cl2', 'les@primus.org', |
308 | 'pwd') |
309 | self.assertRaises(PermissionDenied, dummy_function_mod_req, request, |
310 | - fqdn_listname='foolist@example.org') |
311 | + list_id='foolist.example.org') |
312 | |
313 | @patch.object(Client, 'get_list') |
314 | def test_list_owner(self, mock_get_list): |
315 | @@ -163,13 +163,13 @@ |
316 | self.mock_list.owners = ['les@primus.org'] |
317 | mock_get_list.return_value = self.mock_list |
318 | # prepare request |
319 | - request = self.request_factory.get('/lists/foolist@example.org/' |
320 | + request = self.request_factory.get('/lists/foolist.example.org/' |
321 | 'settings/') |
322 | request.user = User.objects.create_user('les cl3', 'les@primus.org', |
323 | 'pwd') |
324 | return_value = dummy_function_mod_req(request, |
325 | - fqdn_listname= |
326 | - 'foolist@example.org') |
327 | + list_id= |
328 | + 'foolist.example.org') |
329 | self.assertEqual(return_value, True) |
330 | |
331 | @patch.object(Client, 'get_list') |
332 | @@ -179,11 +179,11 @@ |
333 | self.mock_list.moderators = ['les@primus.org'] |
334 | mock_get_list.return_value = self.mock_list |
335 | # prepare request |
336 | - request = self.request_factory.get('/lists/foolist@example.org/' |
337 | + request = self.request_factory.get('/lists/foolist.example.org/' |
338 | 'settings/') |
339 | request.user = User.objects.create_user('les cl4', 'les@primus.org', |
340 | 'pwd') |
341 | return_value = dummy_function_mod_req(request, |
342 | - fqdn_listname= |
343 | - 'foolist@example.org') |
344 | + list_id= |
345 | + 'foolist.example.org') |
346 | self.assertEqual(return_value, True) |
347 | |
348 | === modified file 'src/postorius/urls.py' |
349 | --- src/postorius/urls.py 2014-11-24 19:49:11 +0000 |
350 | +++ src/postorius/urls.py 2015-01-18 19:24:47 +0000 |
351 | @@ -108,7 +108,7 @@ |
352 | url(r'^lists/new/$', 'list_new', name='list_new'), |
353 | url(r'^more_info/(?P<formid>[^/]+)/(?P<helpid>[^/]+)$', |
354 | 'more_info_tab', name='more_info_tab'), |
355 | - url(r'^lists/(?P<fqdn_listname>[^/]+)/', include(per_list_urlpatterns)), |
356 | + url(r'^lists/(?P<list_id>[^/]+)/', include(per_list_urlpatterns)), |
357 | url(r'^users/address_activation/$', |
358 | AddressActivationView.as_view(), |
359 | name='address_activation'), |
360 | |
361 | === modified file 'src/postorius/views/generic.py' |
362 | --- src/postorius/views/generic.py 2014-11-19 11:01:19 +0000 |
363 | +++ src/postorius/views/generic.py 2015-01-18 19:24:47 +0000 |
364 | @@ -45,8 +45,8 @@ |
365 | Sets self.mailing_list to list object if fqdn_listname in **kwargs. |
366 | """ |
367 | |
368 | - def _get_list(self, fqdn_listname, page): |
369 | - return List.objects.get_or_404(fqdn_listname=fqdn_listname) |
370 | + def _get_list(self, list_id, page): |
371 | + return List.objects.get_or_404(fqdn_listname=list_id) |
372 | |
373 | def _is_list_owner(self, user, mailing_list): |
374 | if not user.is_authenticated(): |
375 | @@ -64,9 +64,9 @@ |
376 | |
377 | def dispatch(self, request, *args, **kwargs): |
378 | # get the list object. |
379 | - if 'fqdn_listname' in kwargs: |
380 | + if 'list_id' in kwargs: |
381 | try: |
382 | - self.mailing_list = self._get_list(kwargs['fqdn_listname'], |
383 | + self.mailing_list = self._get_list(kwargs['list_id'], |
384 | int(kwargs.get('page', 1))) |
385 | except MailmanApiError: |
386 | return utils.render_api_error(request) |
387 | |
388 | === modified file 'src/postorius/views/list.py' |
389 | --- src/postorius/views/list.py 2014-11-24 20:46:28 +0000 |
390 | +++ src/postorius/views/list.py 2015-01-18 19:24:47 +0000 |
391 | @@ -44,8 +44,8 @@ |
392 | """Display all members of a given list. |
393 | """ |
394 | |
395 | - def _get_list(self, fqdn_listname, page): |
396 | - m_list = super(ListMembersView, self)._get_list(fqdn_listname, page) |
397 | + def _get_list(self, list_id, page): |
398 | + m_list = super(ListMembersView, self)._get_list(list_id, page) |
399 | m_list.member_page = m_list.get_member_page(25, page) |
400 | m_list.member_page_nr = page |
401 | m_list.member_page_previous_nr = page - 1 |
402 | @@ -54,7 +54,7 @@ |
403 | return m_list |
404 | |
405 | @method_decorator(list_owner_required) |
406 | - def post(self, request, fqdn_listname, page=1): |
407 | + def post(self, request, list_id, page=1): |
408 | if 'owner_email' in request.POST: |
409 | owner_form = NewOwnerForm(request.POST) |
410 | if owner_form.is_valid(): |
411 | @@ -88,7 +88,7 @@ |
412 | context_instance=RequestContext(request)) |
413 | |
414 | @method_decorator(list_owner_required) |
415 | - def get(self, request, fqdn_listname, page=1): |
416 | + def get(self, request, list_id, page=1): |
417 | owner_form = NewOwnerForm() |
418 | moderator_form = NewModeratorForm() |
419 | return render_to_response('postorius/lists/members.html', |
420 | @@ -102,11 +102,11 @@ |
421 | '''View the preferences for a single member of a mailing list''' |
422 | |
423 | @method_decorator(list_owner_required) |
424 | - def post(self, request, fqdn_listname, email): |
425 | + def post(self, request, list_id, email): |
426 | try: |
427 | client = utils.get_client() |
428 | - mm_member = client.get_member(fqdn_listname, email) |
429 | - mm_list = client.get_list(fqdn_listname) |
430 | + mm_member = client.get_member(list_id, email) |
431 | + mm_list = client.get_list(list_id) |
432 | preferences_form = UserPreferences(request.POST) |
433 | if preferences_form.is_valid(): |
434 | preferences = mm_member.preferences |
435 | @@ -134,11 +134,11 @@ |
436 | context_instance=RequestContext(request)) |
437 | |
438 | @method_decorator(list_owner_required) |
439 | - def get(self, request, fqdn_listname, email): |
440 | + def get(self, request, list_id, email): |
441 | try: |
442 | client = utils.get_client() |
443 | - mm_member = client.get_member(fqdn_listname, email) |
444 | - mm_list = client.get_list(fqdn_listname) |
445 | + mm_member = client.get_member(list_id, email) |
446 | + mm_list = client.get_list(list_id) |
447 | settingsform = UserPreferences(initial=mm_member.preferences) |
448 | except MailmanApiError: |
449 | return utils.render_api_error(request) |
450 | @@ -162,7 +162,7 @@ |
451 | """ |
452 | |
453 | @method_decorator(list_owner_required) |
454 | - def get(self, request, fqdn_listname): |
455 | + def get(self, request, list_id): |
456 | return render_to_response('postorius/lists/metrics.html', |
457 | {'list': self.mailing_list}, |
458 | context_instance=RequestContext(request)) |
459 | @@ -173,7 +173,7 @@ |
460 | """Shows common list metrics. |
461 | """ |
462 | |
463 | - def get(self, request, fqdn_listname): |
464 | + def get(self, request, list_id): |
465 | user_email = getattr(request.user, 'email', None) |
466 | userSubscribed = False |
467 | try: |
468 | @@ -195,7 +195,7 @@ |
469 | """Subscribe a mailing list.""" |
470 | |
471 | @method_decorator(login_required) |
472 | - def post(self, request, fqdn_listname): |
473 | + def post(self, request, list_id): |
474 | try: |
475 | form = ListSubscribe(request.POST) |
476 | if form.is_valid(): |
477 | @@ -211,7 +211,7 @@ |
478 | return utils.render_api_error(request) |
479 | except HTTPError, e: |
480 | messages.error(request, e.msg) |
481 | - return redirect('list_summary', self.mailing_list.fqdn_listname) |
482 | + return redirect('list_summary', self.mailing_list.list_id) |
483 | |
484 | |
485 | class ListUnsubscribeView(MailingListView): |
486 | @@ -230,7 +230,7 @@ |
487 | return utils.render_api_error(request) |
488 | except ValueError, e: |
489 | messages.error(request, e) |
490 | - return redirect('list_summary', self.mailing_list.fqdn_listname) |
491 | + return redirect('list_summary', self.mailing_list.list_id) |
492 | |
493 | |
494 | class ListMassSubsribeView(MailingListView): |
495 | @@ -267,7 +267,7 @@ |
496 | return utils.render_api_error(request) |
497 | except HTTPError, e: |
498 | messages.error(request, e) |
499 | - return redirect('mass_subscribe', self.mailing_list.fqdn_listname) |
500 | + return redirect('mass_subscribe', self.mailing_list.list_id) |
501 | |
502 | |
503 | def _get_choosable_domains(request): |
504 | @@ -313,7 +313,7 @@ |
505 | list_settings.save() |
506 | messages.success(request, _("List created")) |
507 | return redirect("list_summary", |
508 | - fqdn_listname=mailing_list.fqdn_listname) |
509 | + list_id=mailing_list.list_id) |
510 | # TODO catch correct Error class: |
511 | except HTTPError, e: |
512 | return render_to_response( |
513 | @@ -344,7 +344,7 @@ |
514 | return utils.render_api_error(request) |
515 | choosable_domains = _get_choosable_domains(request) |
516 | if request.method == 'POST': |
517 | - return redirect("list_summary", fqdn_listname=request.POST["list"]) |
518 | + return redirect("list_summary", list_id=request.POST["list"]) |
519 | else: |
520 | return render_to_response(template, |
521 | {'error': error, |
522 | @@ -354,7 +354,7 @@ |
523 | |
524 | |
525 | @login_required |
526 | -def list_subscriptions(request, option=None, fqdn_listname=None, |
527 | +def list_subscriptions(request, option=None, list_id=None, |
528 | user_email=None, |
529 | template='postorius/lists/subscriptions.html', |
530 | *args, **kwargs): |
531 | @@ -369,11 +369,11 @@ |
532 | error = None |
533 | form_subscribe = None |
534 | form_unsubscribe = None |
535 | - if request.POST.get('fqdn_listname', ''): |
536 | - fqdn_listname = request.POST.get('fqdn_listname', '') |
537 | + if request.POST.get('list_id', ''): |
538 | + list_id = request.POST.get('list_id', '') |
539 | # connect REST and catch issues getting the list |
540 | try: |
541 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
542 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
543 | except AttributeError, e: |
544 | return render_to_response('postorius/errors/generic.html', |
545 | {'error': 'Mailman REST API not available.' |
546 | @@ -444,7 +444,7 @@ |
547 | initial={'fqdn_listname': fqdn_listname, |
548 | 'email': request.user.username, |
549 | 'name': 'unsubscribe'}) |
550 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
551 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
552 | return render_to_response(template, |
553 | {'form_subscribe': form_subscribe, |
554 | 'form_unsubscribe': form_unsubscribe, |
555 | @@ -455,11 +455,11 @@ |
556 | |
557 | |
558 | @list_owner_required |
559 | -def list_delete(request, fqdn_listname): |
560 | +def list_delete(request, list_id): |
561 | """Deletes a list but asks for confirmation first. |
562 | """ |
563 | try: |
564 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
565 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
566 | except MailmanApiError: |
567 | return utils.render_api_error(request) |
568 | if request.method == 'POST': |
569 | @@ -467,7 +467,7 @@ |
570 | return redirect("list_index") |
571 | else: |
572 | submit_url = reverse('list_delete', |
573 | - kwargs={'fqdn_listname': fqdn_listname}) |
574 | + kwargs={'list_id': list_id}) |
575 | cancel_url = reverse('list_index',) |
576 | return render_to_response( |
577 | 'postorius/lists/confirm_delete.html', |
578 | @@ -477,11 +477,11 @@ |
579 | |
580 | |
581 | @list_owner_required |
582 | -def list_held_messages(request, fqdn_listname): |
583 | +def list_held_messages(request, list_id): |
584 | """Shows a list of held messages. |
585 | """ |
586 | try: |
587 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
588 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
589 | except MailmanApiError: |
590 | return utils.render_api_error(request) |
591 | return render_to_response('postorius/lists/held_messages.html', |
592 | @@ -490,71 +490,71 @@ |
593 | |
594 | |
595 | @list_owner_required |
596 | -def accept_held_message(request, fqdn_listname, msg_id): |
597 | +def accept_held_message(request, list_id, msg_id): |
598 | """Accepts a held message. |
599 | """ |
600 | try: |
601 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
602 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
603 | the_list.accept_message(msg_id) |
604 | except MailmanApiError: |
605 | return utils.render_api_error(request) |
606 | except HTTPError, e: |
607 | messages.error(request, e.msg) |
608 | - return redirect('list_held_messages', the_list.fqdn_listname) |
609 | + return redirect('list_held_messages', the_list.list_id) |
610 | messages.success(request, 'The message has been accepted.') |
611 | - return redirect('list_held_messages', the_list.fqdn_listname) |
612 | + return redirect('list_held_messages', the_list.list_id) |
613 | |
614 | |
615 | @list_owner_required |
616 | -def discard_held_message(request, fqdn_listname, msg_id): |
617 | +def discard_held_message(request, list_id, msg_id): |
618 | """Accepts a held message. |
619 | """ |
620 | try: |
621 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
622 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
623 | the_list.discard_message(msg_id) |
624 | except MailmanApiError: |
625 | return utils.render_api_error(request) |
626 | except HTTPError, e: |
627 | messages.error(request, e.msg) |
628 | - return redirect('list_held_messages', the_list.fqdn_listname) |
629 | + return redirect('list_held_messages', the_list.list_id) |
630 | messages.success(request, 'The message has been discarded.') |
631 | - return redirect('list_held_messages', the_list.fqdn_listname) |
632 | + return redirect('list_held_messages', the_list.list_id) |
633 | |
634 | |
635 | @list_owner_required |
636 | -def defer_held_message(request, fqdn_listname, msg_id): |
637 | +def defer_held_message(request, list_id, msg_id): |
638 | """Accepts a held message. |
639 | """ |
640 | try: |
641 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
642 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
643 | the_list.defer_message(msg_id) |
644 | except MailmanApiError: |
645 | return utils.render_api_error(request) |
646 | except HTTPError, e: |
647 | messages.error(request, e.msg) |
648 | - return redirect('list_held_messages', the_list.fqdn_listname) |
649 | + return redirect('list_held_messages', the_list.list_id) |
650 | messages.success(request, 'The message has been defered.') |
651 | - return redirect('list_held_messages', the_list.fqdn_listname) |
652 | + return redirect('list_held_messages', the_list.list_id) |
653 | |
654 | |
655 | @list_owner_required |
656 | -def reject_held_message(request, fqdn_listname, msg_id): |
657 | +def reject_held_message(request, list_id, msg_id): |
658 | """Accepts a held message. |
659 | """ |
660 | try: |
661 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
662 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
663 | the_list.reject_message(msg_id) |
664 | except MailmanApiError: |
665 | return utils.render_api_error(request) |
666 | except HTTPError, e: |
667 | messages.error(request, e.msg) |
668 | - return redirect('list_held_messages', the_list.fqdn_listname) |
669 | + return redirect('list_held_messages', the_list.list_id) |
670 | messages.success(request, 'The message has been rejected.') |
671 | - return redirect('list_held_messages', the_list.fqdn_listname) |
672 | + return redirect('list_held_messages', the_list.list_id) |
673 | |
674 | |
675 | @list_owner_required |
676 | -def list_settings(request, fqdn_listname=None, visible_section=None, |
677 | +def list_settings(request, list_id=None, visible_section=None, |
678 | visible_option=None, |
679 | template='postorius/lists/settings.html'): |
680 | """ |
681 | @@ -572,7 +572,7 @@ |
682 | visible_section = 'List Identity' |
683 | form_sections = [] |
684 | try: |
685 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
686 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
687 | except MailmanApiError: |
688 | return utils.render_api_error(request) |
689 | # collect all Form sections for the links: |
690 | @@ -623,12 +623,12 @@ |
691 | |
692 | |
693 | @user_passes_test(lambda u: u.is_superuser) |
694 | -def remove_role(request, fqdn_listname=None, role=None, address=None, |
695 | +def remove_role(request, list_id=None, role=None, address=None, |
696 | template='postorius/lists/confirm_remove_role.html'): |
697 | """Removes a list moderator or owner. |
698 | """ |
699 | try: |
700 | - the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname) |
701 | + the_list = List.objects.get_or_404(fqdn_listname=list_id) |
702 | except MailmanApiError: |
703 | return utils.render_api_error(request) |
704 | |
705 | @@ -636,12 +636,12 @@ |
706 | if address not in the_list.owners: |
707 | messages.error(request, |
708 | _('The user {} is not an owner'.format(address))) |
709 | - return redirect("list_members", the_list.fqdn_listname) |
710 | + return redirect("list_members", the_list.list_id) |
711 | elif role == 'moderator': |
712 | if address not in the_list.moderators: |
713 | messages.error(request, |
714 | _('The user {} is not a moderator'.format(address))) |
715 | - return redirect("list_members", the_list.fqdn_listname) |
716 | + return redirect("list_members", the_list.list_id) |
717 | |
718 | if request.method == 'POST': |
719 | try: |
720 | @@ -651,13 +651,13 @@ |
721 | except HTTPError as e: |
722 | messages.error(request, _('The {0} could not be removed:' |
723 | ' {1}'.format(role, e.msg))) |
724 | - return redirect("list_members", the_list.fqdn_listname) |
725 | + return redirect("list_members", the_list.list_id) |
726 | messages.success(request, |
727 | _('The user {0} has been removed as {1}.' |
728 | .format(address, role))) |
729 | - return redirect("list_members", the_list.fqdn_listname) |
730 | + return redirect("list_members", the_list.list_id) |
731 | |
732 | return render_to_response(template, |
733 | {'role': role, 'address': address, |
734 | - 'fqdn_listname': the_list.fqdn_listname}, |
735 | + 'list_id': the_list.list_id}, |
736 | context_instance=RequestContext(request)) |
737 | |
738 | === modified file 'src/postorius/views/settings.py' |
739 | --- src/postorius/views/settings.py 2014-11-19 11:01:19 +0000 |
740 | +++ src/postorius/views/settings.py 2015-01-18 19:24:47 +0000 |
741 | @@ -42,7 +42,6 @@ |
742 | MailmanApiError, Mailman404Error) |
743 | from postorius.forms import * |
744 | from postorius.auth.decorators import * |
745 | -from postorius.views.generic import MailingListView, MailmanUserView |
746 | |
747 | |
748 | @login_required |
Hi Abhilash,
thanks again for that bug fix! I just merged it into trunk.
As discussed on IRC I moved the django_nose requirement to a separate dev_requirement .txt.
Cheers
Florian