commit d995ecb41af4d4cb394e89a12983dc168fcf97a3
Author: Paul Kelly <pikelly@blueyonder.co.uk>
Date:   Fri May 14 16:49:33 2010 +0100

    Ensure that all index views and controllers are consistent
    
    Ensures that all controllers use @search in the index method
    Ensure that all index views use pagination

diff --git a/app/controllers/architectures_controller.rb b/app/controllers/architectures_controller.rb
index bd5bd3a13..2f316ce44 100644
--- a/app/controllers/architectures_controller.rb
+++ b/app/controllers/architectures_controller.rb
@@ -1,6 +1,7 @@
 class ArchitecturesController < ApplicationController
   def index
-    @architectures = Architecture.all(:include => :operatingsystems)
+    @search        = Architecture.search(params[:search])
+    @architectures = @search.paginate(:page => params[:page], :include => :operatingsystems)
   end
 
   def new
diff --git a/app/controllers/common_parameters_controller.rb b/app/controllers/common_parameters_controller.rb
index 38f783fab..9da5c3008 100644
--- a/app/controllers/common_parameters_controller.rb
+++ b/app/controllers/common_parameters_controller.rb
@@ -1,6 +1,7 @@
 class CommonParametersController < ApplicationController
   def index
-    @common_parameters = CommonParameter.all
+    @search            = CommonParameter.search(params[:search])
+    @common_parameters = @search.paginate(:page => params[:page])
   end
 
   def new
diff --git a/app/controllers/domains_controller.rb b/app/controllers/domains_controller.rb
index 72ce3ef6d..e3775cb7b 100644
--- a/app/controllers/domains_controller.rb
+++ b/app/controllers/domains_controller.rb
@@ -1,6 +1,7 @@
 class DomainsController < ApplicationController
   def index
-    @domains = Domain.all
+    @search  = Domain.search params[:search]
+    @domains = @search.paginate :page => params[:page], :include => 'hosts'
   end
 
   def new
diff --git a/app/controllers/hostgroups_controller.rb b/app/controllers/hostgroups_controller.rb
index edaedd761..bfa07230c 100644
--- a/app/controllers/hostgroups_controller.rb
+++ b/app/controllers/hostgroups_controller.rb
@@ -1,6 +1,7 @@
 class HostgroupsController < ApplicationController
   def index
-    @hostgroups = Hostgroup.all
+    @search     = Hostgroup.search params[:search]
+    @hostgroups = @search.paginate :page => params[:page]
   end
 
   def new
diff --git a/app/controllers/medias_controller.rb b/app/controllers/medias_controller.rb
index cf0340e6f..cbe73877d 100644
--- a/app/controllers/medias_controller.rb
+++ b/app/controllers/medias_controller.rb
@@ -1,6 +1,7 @@
 class MediasController < ApplicationController
   def index
-    @medias = Media.all(:include => [:operatingsystem])
+    @search = Media.search params[:search]
+    @medias = @search.paginate(:page => params[:page], :include => [:operatingsystem])
   end
 
   def new
diff --git a/app/controllers/models_controller.rb b/app/controllers/models_controller.rb
index 311cc5437..44b659afa 100644
--- a/app/controllers/models_controller.rb
+++ b/app/controllers/models_controller.rb
@@ -1,6 +1,7 @@
 class ModelsController < ApplicationController
   def index
-    @models = Model.all
+    @search = Model.search params[:search]
+    @models = @search.paginate :page => params[:page]
   end
 
   def new
diff --git a/app/controllers/ptables_controller.rb b/app/controllers/ptables_controller.rb
index 60750091c..342049e51 100644
--- a/app/controllers/ptables_controller.rb
+++ b/app/controllers/ptables_controller.rb
@@ -1,6 +1,7 @@
 class PtablesController < ApplicationController
   def index
-    @ptables = Ptable.all(:include => [:operatingsystems])
+    @search  = Ptable.search params[:search]
+    @ptables = @search.paginate(:page => params[:page], :include => [:operatingsystems])
   end
 
   def show
diff --git a/app/models/architecture.rb b/app/models/architecture.rb
index af142883d..b1d765aff 100644
--- a/app/models/architecture.rb
+++ b/app/models/architecture.rb
@@ -9,4 +9,8 @@ class Architecture < ActiveRecord::Base
   def to_s
     name
   end
+
+  def self.per_page
+    25
+  end
 end
diff --git a/app/views/architectures/index.html.erb b/app/views/architectures/index.html.erb
index 4dce45d4e..03e52fe81 100644
--- a/app/views/architectures/index.html.erb
+++ b/app/views/architectures/index.html.erb
@@ -10,9 +10,13 @@
     <tr class="<%= cycle("even", "odd") -%>">
       <td><%= link_to h(architecture.name), edit_architecture_path(architecture) %></td>
       <td><%=h architecture.operatingsystems.to_sentence %></td>
-      <td><%= link_to "Destroy", architecture, :confirm => 'Are you sure?', :method => :delete %></td>
+      <td anign="right">
+        <%= link_to "Destroy", architecture, :confirm => "Delete #{architecture.name}?", :method => :delete %>
+      </td>
     </tr>
   <% end %>
 </table>
+<%= page_entries_info @architectures %>
+<%= will_paginate @architectures %>
 
 <p><%= link_to "New Architecture", new_architecture_path %></p>
diff --git a/app/views/common_parameters/index.html.erb b/app/views/common_parameters/index.html.erb
index 42129eb7b..2b06c5dad 100644
--- a/app/views/common_parameters/index.html.erb
+++ b/app/views/common_parameters/index.html.erb
@@ -9,9 +9,13 @@
     <tr>
       <td><%= link_to h(common_parameter), edit_common_parameter_path(common_parameter)%></td>
       <td><%=h common_parameter.value %></td>
-      <td><%= link_to "Destroy", common_parameter, :confirm => 'Are you sure?', :method => :delete %></td>
+      <td align=""right>
+        <%= link_to "Destroy", common_parameter, :confirm => "Delete #{common_parameter.name}?", :method => :delete %>
+      </td>
     </tr>
   <% end %>
 </table>
+<%= page_entries_info @common_parameters %>
+<%= will_paginate     @common_parameters %>
 
 <p><%= link_to "New Common Parameter", new_common_parameter_path %></p>
diff --git a/app/views/domains/index.html.erb b/app/views/domains/index.html.erb
index 2c1672115..c706e98a0 100644
--- a/app/views/domains/index.html.erb
+++ b/app/views/domains/index.html.erb
@@ -10,9 +10,11 @@
     <tr class="<%= cycle("even", "odd") -%>">
       <td><%= link_to h(domain.fullname.empty? ? domain.name : domain.fullname), edit_domain_path(domain)%></td>
       <td><%= domain.hosts.size %>
-      <td><%= link_to "Destroy", domain, :confirm => 'Are you sure?', :method => :delete %></td>
+      <td align="right"> <%= link_to "Destroy", domain, :confirm => 'Are you sure?', :method => :delete %></td>
     </tr>
   <% end %>
 </table>
+<%= page_entries_info @domains %>
+<%= will_paginate     @domains %>
 
 <p><%= link_to "New Domain", new_domain_path %></p>
diff --git a/app/views/hostgroups/index.html.erb b/app/views/hostgroups/index.html.erb
index 693b2c60b..4d508cbcc 100644
--- a/app/views/hostgroups/index.html.erb
+++ b/app/views/hostgroups/index.html.erb
@@ -3,13 +3,17 @@
 <table class="list">
   <tr>
     <th>Name</th>
+    <th></th>
   </tr>
   <% for hostgroup in @hostgroups %>
     <tr class="<%= cycle("even", "odd") -%>">
       <td><%=link_to h(hostgroup.name), edit_hostgroup_path(hostgroup) %></td>
-      <td><%= link_to "Destroy", hostgroup, :confirm => 'Are you sure?', :method => :delete %></td>
+      <td align="right">
+        <%= link_to "Destroy", hostgroup, :confirm => 'Are you sure?', :method => :delete %>
+      </td>
     </tr>
   <% end %>
 </table>
-
+<%= page_entries_info @hostgroups %>
+<%= will_paginate     @hostgroups %>
 <p><%= link_to "New Hostgroup", new_hostgroup_path %></p>
diff --git a/app/views/medias/index.html.erb b/app/views/medias/index.html.erb
index b0536d039..b546414a2 100644
--- a/app/views/medias/index.html.erb
+++ b/app/views/medias/index.html.erb
@@ -5,15 +5,19 @@
     <th>Name</th>
     <th>Path</th>
     <th>Operatingsystem</th>
+    <th></th>
   </tr>
   <% for media in @medias %>
     <tr>
       <td><%= link_to h(media), edit_media_path(media) %></td>
       <td><%=h media.path %></td>
       <td><%=h media.operatingsystem %></td>
-      <td><%= link_to "Destroy", media, :confirm => 'Are you sure?', :method => :delete %></td>
+      <td align="right">
+        <%= link_to "Destroy", media, :confirm => "Delete #{media.name}?", :method => :delete %>
+      </td>
     </tr>
   <% end %>
 </table>
-
+<%= page_entries_info @medias %>
+<%= will_paginate     @medias %>
 <p><%= link_to "New Media", new_media_path %></p>
diff --git a/app/views/models/index.html.erb b/app/views/models/index.html.erb
index db707478c..386dda0b6 100644
--- a/app/views/models/index.html.erb
+++ b/app/views/models/index.html.erb
@@ -10,11 +10,13 @@
     <tr class="<%= cycle("even", "odd") -%>">
       <td><%=link_to h(model.name), edit_model_path(model)%></td>
       <td><%= model.hosts.count %></td>
-      <td><%= link_to "Destroy", model, :confirm => 'Are you sure?', :method => :delete %></td>
+      <td align="right">
+        <%= link_to "Destroy", model, :confirm => "Delete #{model.name}?", :method => :delete %>
+      </td>
     </tr>
   <% end %>
 </table>
-
-Found <%= @models.size %> models
+<%= page_entries_info @models %>
+<%= will_paginate     @models %>
 
 <p><%= link_to "New Model", new_model_path %></p>
diff --git a/app/views/operatingsystems/index.html.erb b/app/views/operatingsystems/index.html.erb
index 8c0f62ee6..7b9e18276 100644
--- a/app/views/operatingsystems/index.html.erb
+++ b/app/views/operatingsystems/index.html.erb
@@ -10,7 +10,9 @@
     <tr class="<%= cycle("even", "odd") -%>">
       <td><%= link_to h(operatingsystem.to_label), edit_operatingsystem_path(operatingsystem) %></td>
       <td><%= h operatingsystem.family %></td>
-      <td><%= link_to "Destroy", operatingsystem, :confirm => "Delete #{operatingsystem.fullname}?", :method => :delete %></td>
+      <td align="right">
+        <%= link_to "Destroy", operatingsystem, :confirm => "Delete #{operatingsystem.fullname}?", :method => :delete %>
+      </td>
     </tr>
   <% end %>
 </table>
diff --git a/app/views/ptables/index.html.erb b/app/views/ptables/index.html.erb
index 763745477..dc8d31331 100644
--- a/app/views/ptables/index.html.erb
+++ b/app/views/ptables/index.html.erb
@@ -4,17 +4,19 @@
   <tr>
     <th>Name</th>
     <th>Operatingsystems</th>
-    <th></th><th></th><th></th>
+    <th></th>
   </tr>
   <% for ptable in @ptables %>
     <tr class="<%= cycle("even", "odd") -%>">
-      <td><%=h ptable.name %></td>
+      <td><%=link_to h(ptable.name), edit_ptable_path(ptable) %></td>
       <td><%=h ptable.operatingsystems.to_sentence %></td>
-      <td><%= link_to "Show", ptable %></td>
-      <td><%= link_to "Edit", edit_ptable_path(ptable) %></td>
-      <td><%= link_to "Destroy", ptable, :confirm => 'Are you sure?', :method => :delete %></td>
+      <td align="right">
+        <%= link_to "Destroy", ptable, :confirm => "Delete #{ptable.name}?", :method => :delete %>
+      </td>
     </tr>
   <% end %>
 </table>
+<%= page_entries_info @ptables %>
+<%= will_paginate     @ptables %>
 
 <p><%= link_to "New Partition table layout", new_ptable_path %></p>
diff --git a/app/views/puppetclasses/index.html.erb b/app/views/puppetclasses/index.html.erb
index 254ef9bae..635dccd3c 100644
--- a/app/views/puppetclasses/index.html.erb
+++ b/app/views/puppetclasses/index.html.erb
@@ -10,6 +10,7 @@
     <th>Operatingsystems</th>
     <th>Environments</th>
     <th>Host Groups</th>
+    <th></th>
   </tr>
   <% for puppetclass in @puppetclasses %>
     <tr class="<%= cycle("even", "odd") -%>">
@@ -17,7 +18,9 @@
       <td><%=h puppetclass.operatingsystems.to_sentence %></td>
       <td><%=h puppetclass.environments.to_sentence %></td>
       <td><%=h puppetclass.hostgroups.to_sentence %></td>
-      <td><%= link_to "Destroy", puppetclass, :confirm => 'Are you sure?', :method => :delete %></td>
+      <td align="right">
+        <%= link_to "Destroy", puppetclass, :confirm => "Delete #{puppetclass.name}?", :method => :delete %>
+      </td>
     </tr>
   <% end %>
 </table>
