ref: refs/heads/master
commit cc920484d2440643b1966486973169ab9bad9840
Author: Klaus Kämpf
Date: Wed Jul 15 09:52:39 2009 +0200
Consistently name the host id "hostid" in urls
I'd rather name it 'host' but new_session_path (as used in
app/views/hosts/index.html.erb) takes it as a reserved parameter.
---
webclient/app/controllers/sessions_controller.rb | 12 +++++-----
webclient/app/views/hosts/index.html.erb | 23 ++++++++++++++-------
webclient/app/views/sessions/new.rhtml | 2 +-
3 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/webclient/app/controllers/sessions_controller.rb b/webclient/app/controllers/sessions_controller.rb
index e6b404f..9dc5cd4 100644
--- a/webclient/app/controllers/sessions_controller.rb
+++ b/webclient/app/controllers/sessions_controller.rb
@@ -29,7 +29,7 @@ class SessionsController < ApplicationController
return
end
- @host = Host.find(params[:target]) rescue nil
+ @host = Host.find(params[:hostid]) rescue nil
# if the hostname is not set, go to the host controller
# to pickup a service
unless @host
@@ -47,17 +47,17 @@ class SessionsController < ApplicationController
# if the create action is called without the hostname
# it will show the login form
def create
- host = Host.find(params[:host]) rescue nil
+ host = Host.find(params[:hostid]) rescue nil
# if the user or password is not there, then render the login form
if host.nil?
flash[:warning] = _("You need to specify the host")
redirect_to :action => "new"
elsif params[:login].blank?
flash[:warning] = _("No login specified")
- redirect_to :action => "new", :host => host.id
+ redirect_to :action => "new", :hostid => host.id
elsif params[:password].blank?
flash[:warning] = _("No password specified")
- redirect_to :action => "new", :login => params[:login], :host => host.id
+ redirect_to :action => "new", :login => params[:login], :hostid => host.id
else
# otherwise, we have all the data, try to login
begin
@@ -74,7 +74,7 @@ class SessionsController < ApplicationController
logger.warn e.to_s
logger.info e.backtrace.join("\n")
flash[:error] = _("Exception raised when trying to login to #{host.name}. Please try again")
- redirect_to :action => "new", :host => host.id
+ redirect_to :action => "new", :hostid => host.id
return
end
@@ -97,7 +97,7 @@ class SessionsController < ApplicationController
session[:user] = session[:host] = nil
#show # getting hosts again
flash[:warning] = _("Login incorrect. Check your username and password.")
- redirect_to :action => "new", :host => host.id
+ redirect_to :action => "new", :hostid => host.id
end
end
end
diff --git a/webclient/app/views/hosts/index.html.erb b/webclient/app/views/hosts/index.html.erb
index b2bd41f..bc7ab27 100644
--- a/webclient/app/views/hosts/index.html.erb
+++ b/webclient/app/views/hosts/index.html.erb
@@ -5,12 +5,19 @@
<table id="services-list" class="list">
<tbody>
<% for host in @hosts %>
- <tr class="service-item">
- <td class="icon"><div class="container"><img src="/icons/yast-service-22.png"></div></td>
- <td><div class="title"><%= link_to host.name, new_session_path(:target => "#{host.id}") %></div></td>
- <!-- uh, oh, cannot use :host here ?! -->
- <td><div class="label"><%=h host.url %></div></td>
- <td><div class="label"><%=h host.description %></div></td>
+ <tr class="host-item">
+ <td class="icon">
+ <div class="container"><img src="/icons/yast-service-22.png"></div>
+ </td>
+ <td>
+ <div class="title"><%= link_to host.name, new_session_path(:hostid => "#{host.id}") %></div>
+ </td>
+ <td>
+ <div class="label"><%=h host.url %></div>
+ </td>
+ <td>
+ <div class="label"><%=h host.description %></div>
+ </td>
<td class="icon">
<div class="container">
<%= link_to image_tag("/images/edit-icon.gif", :alt => "edit"),
@@ -20,7 +27,7 @@
<td class="icon">
<div class="container">
<%= link_to image_tag("/images/delete.png", :alt => "delete"),
- host, :confirm => _('Are you sure?'), :method => :delete %>
+ host, :confirm => _("Really delete host #{host.name} ?"), :method => :delete %>
</div>
</td>
@@ -29,7 +36,7 @@
</tbody>
</table>
- <input class="button jqModal" type="submit" value="Add" id="add_host" />
+ <input class="button jqModal" type="submit" value="Add" id="add-host" />
Reply