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

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
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 (community) Needs Fixing
Raphaël Badin (community) Approve
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.
Revision history for this message
Raphaël Badin (rvb) :
review: Approve
Revision history for this message
Adam Collard (adam-collard) :
review: Needs Fixing

Preview Diff

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

Subscribers

People subscribed via source and target branches

to all changes: