https://svn.lrde.epita.fr/svn/ranch/trunk
Index: ChangeLog
from Nicolas Despr�s <nicolas.despres(a)gmail.com>
Add the show request to the systems controller.
* web/ranch/app/controllers/systems_controller.rb: Add the show
request.
* web/ranch/test/functional/systems_controller_test.rb: Test the show
request.
* web/ranch/app/views/systems/list.rhtml: Hostnames are links to the
information view..
* web/ranch/app/views/systems/show.rhtml: New. View of the show
request.
* web/ranch/app/views/systems/_menubar.rhtml: Add the `Information'
menu item.
app/controllers/systems_controller.rb | 4 ++++
app/views/systems/_menubar.rhtml | 11 +++++++++--
app/views/systems/list.rhtml | 7 +++++++
app/views/systems/show.rhtml | 16 ++++++++++++++++
test/functional/systems_controller_test.rb | 16 ++++++++++++++++
5 files changed, 52 insertions(+), 2 deletions(-)
Index: web/ranch/test/functional/systems_controller_test.rb
--- web/ranch/test/functional/systems_controller_test.rb (revision 56)
+++ web/ranch/test/functional/systems_controller_test.rb (working copy)
@@ -27,4 +27,20 @@
assert_not_nil assigns(:systems)
end
+ def test_show_with_id
+ get :show, { :system_id => 1 }
+ assert_response :success
+ assert_template "show"
+
+ assert_not_nil assigns(:system)
+ end
+
+ def test_show_without_id
+ get :show
+ assert_response :success
+ assert_template "show"
+
+ assert_nil assigns(:system)
+ end
+
end
Index: web/ranch/app/controllers/systems_controller.rb
--- web/ranch/app/controllers/systems_controller.rb (revision 56)
+++ web/ranch/app/controllers/systems_controller.rb (working copy)
@@ -10,4 +10,8 @@
@systems = System.find :all, :order => "hostname"
end
+ def show
+ @system = System.find_by_id params[:system_id]
+ end
+
end
Index: web/ranch/app/views/systems/list.rhtml
--- web/ranch/app/views/systems/list.rhtml (revision 56)
+++ web/ranch/app/views/systems/list.rhtml (working copy)
@@ -16,8 +16,15 @@
<% for system in @systems do %>
<tr>
<% for column in columns do %>
+ <% if column.name == "hostname" %>
+ <td>
+ <%= link_to system.hostname, :action => "show",
+ :system_id => system.id %>
+ </td>
+ <% else %>
<%= content_tag "td", system.send(column.name) %>
<% end %>
+ <% end %>
</tr>
<% end %>
</table>
Index: web/ranch/app/views/systems/show.rhtml
--- web/ranch/app/views/systems/show.rhtml (revision 0)
+++ web/ranch/app/views/systems/show.rhtml (revision 0)
@@ -0,0 +1,16 @@
+ <!-- -*- html -*- -->
+
+<p>
+<% if @system.nil? %>
+ Select a system in the list first.
+<% else %>
+ <table>
+ <% for column in System.columns do %>
+ <tr>
+ <%= content_tag "td", "#{column.name}:" %>
+ <%= content_tag "td", @system.send(column.name) %>
+ </tr>
+ <% end %>
+ </table>
+<% end %>
+</p>
Index: web/ranch/app/views/systems/_menubar.rhtml
--- web/ranch/app/views/systems/_menubar.rhtml (revision 56)
+++ web/ranch/app/views/systems/_menubar.rhtml (working copy)
@@ -2,8 +2,15 @@
<table>
<tr>
<td>
- <%= link_to "List", :controller => "systems",
- :action => "list" %>
+ <%= link_to "List", :action => "list" %>
+ </td>
+ <td>
+ <% if @system.nil? %>
+ <%= link_to "Information", :action => "show" %>
+ <% else %>
+ <%= link_to "Information", :action => "show",
+ :system_id => @system.id %>
+ <% end %>
</td>
</tr>
</table>