← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/maas-view-node into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/maas-view-node into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/maas-view-node/+merge/98417

This branch adds a simple "view node" page.  Right now it's pretty minimal but later we will add buttons that will allow the user to interact with that node.
-- 
https://code.launchpad.net/~rvb/maas/maas-view-node/+merge/98417
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-view-node into lp:maas.
=== modified file 'src/maasserver/templates/maasserver/node_list.html'
--- src/maasserver/templates/maasserver/node_list.html	2012-03-05 02:55:44 +0000
+++ src/maasserver/templates/maasserver/node_list.html	2012-03-20 15:40:23 +0000
@@ -39,7 +39,11 @@
         </thead>
         {% for node in node_list %}
           <tr class="node {% cycle 'even' 'odd' %}">
-            <td>{{ node.hostname }}</td>
+            <td>
+              <a href="{% url 'node-view' node.id %}">
+                {{ node.hostname }}
+              </a>
+            </td>
             <td>
               {{ node.macaddress_set.reverse|first }}
               {% if node.macaddress_set.count > 1 %}

=== added file 'src/maasserver/templates/maasserver/node_view.html'
--- src/maasserver/templates/maasserver/node_view.html	1970-01-01 00:00:00 +0000
+++ src/maasserver/templates/maasserver/node_view.html	2012-03-20 15:40:23 +0000
@@ -0,0 +1,35 @@
+{% extends "maasserver/base.html" %}
+
+{% block nav-active-settings %}active{% endblock %}
+{% block title %}Node: {{ node.hostname }}{% endblock %}
+{% block page-title %}Node: {{ node.hostname }}{% endblock %}
+{% block layout-modifiers %}sidebar{% endblock %}
+
+{% block sidebar %}
+  <div class="block size3">
+  </div>
+{% endblock %}
+
+{% block content %}
+  <ul class="data-list">
+    <li class="block size2 first">
+      <h4>Hostname</h4>
+      <span>{{ node.hostname }}</span>
+    </li>
+    <li class="block size3">
+      <h4>MAC addresses</h4>
+      <span>
+          {% for mac in node.macaddress_set.all %}
+          {{ mac }}{% if not forloop.last %}, {% endif %}
+          {% endfor %}
+      </span>
+    </li>
+    <li class="block size3">
+      <h4>Status</h4>
+      <span>
+          {{ node.display_status }}
+      </span>
+    </li>
+  </ul>
+{% endblock %}
+

=== modified file 'src/maasserver/tests/test_views.py'
--- src/maasserver/tests/test_views.py	2012-03-19 13:13:06 +0000
+++ src/maasserver/tests/test_views.py	2012-03-20 15:40:23 +0000
@@ -357,6 +357,28 @@
         self.assertNotEqual(old_pw, user.password)
 
 
+class NodeViewTest(LoggedInTestCase):
+
+    def test_node_list_contains_link_to_node_view(self):
+        node = factory.make_node()
+        response = self.client.get(reverse('node-list'))
+        doc = fromstring(response.content)
+        content_node = doc.cssselect('#content')[0]
+        all_links = [elem.get('href') for elem in content_node.cssselect('a')]
+        node_link = reverse('node-view', args=[node.id])
+        self.assertIn(node_link, all_links)
+
+    def test_view_node_displays_node_info(self):
+        # The node page features the basic information about the node.
+        node = factory.make_node()
+        node_link = reverse('node-view', args=[node.id])
+        response = self.client.get(node_link)
+        doc = fromstring(response.content)
+        content_text = doc.cssselect('#content')[0].text_content()
+        self.assertIn(node.hostname, content_text)
+        self.assertIn(node.display_status(), content_text)
+
+
 class AdminLoggedInTestCase(LoggedInTestCase):
 
     def setUp(self):

=== modified file 'src/maasserver/urls.py'
--- src/maasserver/urls.py	2012-03-19 12:23:46 +0000
+++ src/maasserver/urls.py	2012-03-20 15:40:23 +0000
@@ -36,6 +36,7 @@
     logout,
     NodeListView,
     NodesCreateView,
+    NodeView,
     proxy_to_longpoll,
     settings,
     settings_add_archive,
@@ -73,6 +74,7 @@
         NodeListView.as_view(template_name="maasserver/index.html"),
         name='index'),
     url(r'^nodes/$', NodeListView.as_view(model=Node), name='node-list'),
+    url(r'^nodes/(?P<id>\d*)/view/$', NodeView.as_view(), name='node-view'),
     url(
         r'^nodes/create/$', NodesCreateView.as_view(), name='node-create'),
 )

=== modified file 'src/maasserver/views.py'
--- src/maasserver/views.py	2012-03-19 13:13:06 +0000
+++ src/maasserver/views.py	2012-03-20 15:40:23 +0000
@@ -13,6 +13,7 @@
     "logout",
     "NodeListView",
     "NodesCreateView",
+    "NodeView",
     ]
 
 import mimetypes
@@ -85,6 +86,17 @@
     return dj_logout(request, next_page=reverse('login'))
 
 
+class NodeView(DetailView):
+
+    template_name = 'maasserver/node_view.html'
+
+    context_object_name = 'node'
+
+    def get_object(self):
+        id = self.kwargs.get('id', None)
+        return get_object_or_404(Node, id=id)
+
+
 def get_longpoll_context():
     if messaging is not None and django_settings.LONGPOLL_PATH is not None:
         return {