Merge lp:~rvb/maas/zone-listing-pagination into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 2167
Proposed branch: lp:~rvb/maas/zone-listing-pagination
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 45 lines (+17/-1)
2 files modified
src/maasserver/templates/maasserver/zone_list.html (+1/-0)
src/maasserver/views/tests/test_zones.py (+16/-1)
To merge this branch: bzr merge lp:~rvb/maas/zone-listing-pagination
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+212578@code.launchpad.net

Commit message

Fix zone listing: add pagination.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

I see you applied the comments from my other review here as well. That's why I put this one off for a while. :) Thanks.

The "Create 4 zones" comment probably makes a bit more sense here than the "Create 4 networks" one in the other branch. But when you add it to the two-line list comprehension, it's not much nicer than the loop it replaces... Maybe just put the list comprehension on a single line?

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

> I see you applied the comments from my other review here as well. That's why
> I put this one off for a while. :) Thanks.
>
> The "Create 4 zones" comment probably makes a bit more sense here than the
> "Create 4 networks" one in the other branch. But when you add it to the two-
> line list comprehension, it's not much nicer than the loop it replaces...
> Maybe just put the list comprehension on a single line?

Right, done.

Thanks for the review!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/templates/maasserver/zone_list.html'
2--- src/maasserver/templates/maasserver/zone_list.html 2014-02-07 14:30:24 +0000
3+++ src/maasserver/templates/maasserver/zone_list.html 2014-03-25 12:43:54 +0000
4@@ -65,6 +65,7 @@
5 {% endfor %}
6 </tbody>
7 </table>
8+ {% include "maasserver/pagination.html" %}
9 {% if user.is_superuser %}
10 <a class="button right space-top-small" href="{% url 'zone-add' %}">
11 Add zone
12
13=== modified file 'src/maasserver/views/tests/test_zones.py'
14--- src/maasserver/views/tests/test_zones.py 2014-03-05 02:20:03 +0000
15+++ src/maasserver/views/tests/test_zones.py 2014-03-25 12:43:54 +0000
16@@ -30,7 +30,10 @@
17 )
18 from maasserver.testing.factory import factory
19 from maasserver.testing.testcase import MAASServerTestCase
20-from maasserver.views.zones import ZoneAdd
21+from maasserver.views.zones import (
22+ ZoneAdd,
23+ ZoneListView,
24+ )
25 from testtools.matchers import (
26 Contains,
27 ContainsAll,
28@@ -118,6 +121,18 @@
29 add_link = reverse('zone-add')
30 self.assertNotIn(add_link, get_content_links(response))
31
32+ def test_zone_listing_is_paginated(self):
33+ self.patch(ZoneListView, "paginate_by", 3)
34+ self.client_log_in(as_admin=True)
35+ # Create 4 zones.
36+ [factory.make_zone() for _ in range(4)]
37+ response = self.client.get(reverse('zone-list'))
38+ self.assertEqual(httplib.OK, response.status_code)
39+ doc = fromstring(response.content)
40+ self.assertEqual(
41+ 1, len(doc.cssselect('div.pagination')),
42+ "Couldn't find pagination tag.")
43+
44
45 class ZoneListingViewTestAdmin(MAASServerTestCase):
46