launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12702
[Merge] lp:~jameinel/maas/node-view-has-tags into lp:maas
John A Meinel has proposed merging lp:~jameinel/maas/node-view-has-tags into lp:maas.
Commit message:
Update the node-view pages to show what tags are attached to the node.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jameinel/maas/node-view-has-tags/+merge/127150
First step on exposing tags in the HTML UI.
This creates a list (like the mac_address) to see what tags are attached to a node. Eventually these will be hyperlinks, but I need to do the views for Tag first.
--
https://code.launchpad.net/~jameinel/maas/node-view-has-tags/+merge/127150
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jameinel/maas/node-view-has-tags into lp:maas.
=== modified file 'src/maasserver/templates/maasserver/node_view.html'
--- src/maasserver/templates/maasserver/node_view.html 2012-06-28 12:05:09 +0000
+++ src/maasserver/templates/maasserver/node_view.html 2012-09-30 11:52:05 +0000
@@ -51,6 +51,14 @@
</span>
</li>
<li class="block size3">
+ <h4>Tags</h4>
+ <span>
+ {% for tag in node.tags.all %}
+ {{ tag }}{% if not forloop.last %}, {% endif %}
+ {% endfor %}
+ </span>
+ </li>
+ <li class="block size3">
<h4>Status</h4>
<span>
{{ node.display_status }}
=== modified file 'src/maasserver/tests/test_views_nodes.py'
--- src/maasserver/tests/test_views_nodes.py 2012-09-27 02:37:18 +0000
+++ src/maasserver/tests/test_views_nodes.py 2012-09-30 11:52:05 +0000
@@ -107,6 +107,21 @@
self.assertIn(node.display_status(), content_text)
self.assertIn(self.logged_in_user.username, content_text)
+ def test_view_node_contains_tag_names(self):
+ node = factory.make_node(owner=self.logged_in_user)
+ tag_a = factory.make_tag(name='special-tag-name')
+ tag_b = factory.make_tag(name='alternative-tag-name')
+ node.tags.add(tag_a)
+ node.tags.add(tag_b)
+ node_link = reverse('node-view', args=[node.system_id])
+ response = self.client.get(node_link)
+ doc = fromstring(response.content)
+ content_text = doc.cssselect('#content')[0].text_content()
+ self.assertIn(tag_a.name, content_text)
+ self.assertIn(tag_b.name, content_text)
+ # tag_link = reverse('tags', args=[tag.name])
+ # self.assertIn(tag_link, get_content_links(response))
+
def test_view_node_displays_node_info_no_owner(self):
# If the node has no owner, the Owner 'slot' does not exist.
node = factory.make_node()
=== added file 'src/maasserver/tests/test_views_tags.py'
--- src/maasserver/tests/test_views_tags.py 1970-01-01 00:00:00 +0000
+++ src/maasserver/tests/test_views_tags.py 2012-09-30 11:52:05 +0000
@@ -0,0 +1,38 @@
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Test maasserver nodes views."""
+
+from __future__ import (
+ absolute_import,
+ print_function,
+ unicode_literals,
+ )
+
+__metaclass__ = type
+__all__ = []
+
+from django.core.urlresolvers import reverse
+from lxml.html import fromstring
+# from maasserver.models import (
+# MACAddress,
+# Node,
+# Tag,
+# )
+from maasserver.testing import (
+ extract_redirect,
+ get_content_links,
+ reload_object,
+ )
+from maasserver.testing.factory import factory
+from maasserver.testing.rabbit import uses_rabbit_fixture
+from maasserver.testing.testcase import (
+ AdminLoggedInTestCase,
+ LoggedInTestCase,
+ TestCase,
+ )
+
+
+class TagViewsTest(LoggedInTestCase):
+
+ pass
=== modified file 'src/maasserver/urls.py'
--- src/maasserver/urls.py 2012-06-26 13:30:48 +0000
+++ src/maasserver/urls.py 2012-09-30 11:52:05 +0000
@@ -51,6 +51,9 @@
settings,
settings_add_archive,
)
+from maasserver.views.tags import (
+ TagView,
+ )
def adminurl(regexp, view, *args, **kwargs):
@@ -142,6 +145,14 @@
name='accounts-del'),
)
+# Tag views.
+urlpatterns += patterns('maasserver.views',
+ # url(r'^tags/$', TagListView.as_view(), name='tag-list'),
+ url(r'^tags/(?P<name>[\w\-]+)/view/$', TagView.as_view(), name='tag-view'),
+ # url(r'^tags/(?P<name>[\w\-]+)/edit/$', TagEdit.as_view(), name='tag-edit'),
+ # url(r'^tags/(?P<name>[\w\-]+)/delete/$', TagDelete.as_view(),
+ # name='tag-delete'),
+)
# API URLs.
urlpatterns += patterns('',
=== modified file 'src/maasserver/views/nodes.py'
--- src/maasserver/views/nodes.py 2012-06-22 09:45:30 +0000
+++ src/maasserver/views/nodes.py 2012-09-30 11:52:05 +0000
@@ -165,6 +165,7 @@
node.error if node.status == NODE_STATUS.FAILED_TESTS else None)
context['status_text'] = (
node.error if node.status != NODE_STATUS.FAILED_TESTS else None)
+ context['tag_names'] = node.tags
return context
def dispatch(self, *args, **kwargs):
=== added file 'src/maasserver/views/tags.py'
--- src/maasserver/views/tags.py 1970-01-01 00:00:00 +0000
+++ src/maasserver/views/tags.py 2012-09-30 11:52:05 +0000
@@ -0,0 +1,33 @@
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Tag views."""
+
+from __future__ import (
+ absolute_import,
+ print_function,
+ unicode_literals,
+ )
+
+__metaclass__ = type
+__all__ = [
+ 'TagView',
+ ]
+
+from maasserver.models import Tag
+
+
+class TagView:
+ """Basic view of a tag.
+ """
+
+ context_object_name = 'tag'
+
+ def get_object(self):
+ system_id = self.kwargs.get('name', None)
+ tag = Tag.objects.get_tag_or_404(
+ name=name, user=self.request.user,
+ to_edit=False)
+ return tag
+
+