Merge lp:~rvb/maas/bug-1413030-1.7 into lp:maas/1.7

Proposed by Raphaël Badin on 2015-01-21
Status: Merged
Approved by: Raphaël Badin on 2015-01-21
Approved revision: 3338
Merged at revision: 3338
Proposed branch: lp:~rvb/maas/bug-1413030-1.7
Merge into: lp:maas/1.7
Diff against target: 83 lines (+56/-2)
2 files modified
src/maasserver/templates/maasserver/snippets.html (+9/-2)
src/maasserver/views/tests/test_snippets.py (+47/-0)
To merge this branch: bzr merge lp:~rvb/maas/bug-1413030-1.7
Reviewer Review Type Date Requested Status
Adam Collard Needs Fixing on 2015-01-22
Raphaël Badin (community) Approve on 2015-01-21
Review via email: mp+247169@code.launchpad.net

Commit message

Backport revision 3482: Also hide the labels when the fields themselves are hidden in the add_node HTML snippet.

To post a comment you must log in.
Raphaël Badin (rvb) :
review: Approve
review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/templates/maasserver/snippets.html'
2--- src/maasserver/templates/maasserver/snippets.html 2014-10-02 20:19:38 +0000
3+++ src/maasserver/templates/maasserver/snippets.html 2015-01-21 16:39:27 +0000
4@@ -7,6 +7,7 @@
5 </p>
6 </script>
7 <script type="text/x-template" id="add-node">
8+<<<<<<< TREE
9 <p>
10 <label for="id_hostname">Hostname
11 <span class="form-optional">(optional)</span>
12@@ -17,11 +18,17 @@
13 </div>
14 </p>
15 <p>
16- <label for="id_osystem">OS</label>
17+ <label
18+ for="id_osystem"
19+ class="{% if node_form.osystem.is_hidden %}hidden{% endif %}">
20+ OS</label>
21 {{ node_form.osystem }}
22 </p>
23 <p>
24- <label for="id_distro_series">Release</label>
25+ <label
26+ for="id_distro_series"
27+ class="{% if node_form.distro_series.is_hidden %}hidden{% endif %}">
28+ Release</label>
29 {{ node_form.distro_series }}
30 </p>
31 <p class="license_key hidden">
32
33=== added file 'src/maasserver/views/tests/test_snippets.py'
34--- src/maasserver/views/tests/test_snippets.py 1970-01-01 00:00:00 +0000
35+++ src/maasserver/views/tests/test_snippets.py 2015-01-21 16:39:27 +0000
36@@ -0,0 +1,47 @@
37+# Copyright 2015 Canonical Ltd. This software is licensed under the
38+# GNU Affero General Public License version 3 (see the file LICENSE).
39+
40+"""Test maasserver snippets."""
41+
42+from __future__ import (
43+ absolute_import,
44+ print_function,
45+ unicode_literals,
46+ )
47+
48+str = None
49+
50+__metaclass__ = type
51+__all__ = []
52+
53+
54+from django.core.urlresolvers import reverse
55+from lxml.html import fromstring
56+from maasserver.testing.testcase import MAASServerTestCase
57+from testtools.matchers import (
58+ HasLength,
59+ Not,
60+ )
61+
62+
63+class SnippetsTest(MAASServerTestCase):
64+
65+ def test_index_page_containts_add_node_snippet(self):
66+ self.client_log_in()
67+ index_page = self.client.get(reverse('index'))
68+ doc = fromstring(index_page.content)
69+ self.assertEqual(
70+ 'text/x-template', doc.cssselect('#add-node')[0].attrib['type'])
71+
72+ def test_add_node_snippet_hides_osystem_distro_series_labels(self):
73+ self.client_log_in()
74+ index_page = self.client.get(reverse('index'))
75+ doc = fromstring(index_page.content)
76+ content_text = doc.cssselect('#add-node')[0].text_content()
77+ add_node_snippet = fromstring(content_text)
78+ self.expectThat(
79+ add_node_snippet.cssselect("label[for=id_osystem].hidden"),
80+ Not(HasLength(0)), "No hidden id_osystem label")
81+ self.expectThat(
82+ add_node_snippet.cssselect("label[for=id_distro_series].hidden"),
83+ Not(HasLength(0)), "No hidden id_distro_series label")

Subscribers

People subscribed via source and target branches

to all changes: