From 7bb03ac91ff61b35e8b51d68d9538b04cf96a794 Mon Sep 17 00:00:00 2001 From: francis Date: Tue, 30 Oct 2007 14:49:07 +0000 Subject: Remove last index action and rename it show - index is confusing as an action name as it isn't clear if it is going to be list or show. --- app/controllers/user_controller.rb | 4 ++-- app/views/user/index.rhtml | 21 --------------------- app/views/user/show.rhtml | 21 +++++++++++++++++++++ config/routes.rb | 5 +++-- todo.txt | 3 --- 5 files changed, 26 insertions(+), 28 deletions(-) delete mode 100644 app/views/user/index.rhtml create mode 100644 app/views/user/show.rhtml diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 2bcb0203a..3daab0670 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -4,10 +4,10 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user_controller.rb,v 1.3 2007-10-26 18:00:26 francis Exp $ +# $Id: user_controller.rb,v 1.4 2007-10-30 14:49:08 francis Exp $ class UserController < ApplicationController - def index + def show @display_users = User.find(:all, :conditions => [ "name = ?", params[:name] ], :order => "created_at desc") end diff --git a/app/views/user/index.rhtml b/app/views/user/index.rhtml deleted file mode 100644 index 3e2668d01..000000000 --- a/app/views/user/index.rhtml +++ /dev/null @@ -1,21 +0,0 @@ -<% @title = h(@display_users[0].name) %> - -<% if (@display_users.size > 1) %> -

There is more than one user with this name. -<% end%> - -<% for display_user in @display_users %> -

<%=@title%>

-

Joined on <%= simple_date(display_user.created_at) %>

- -

Freedom of Information requests made by this person:

- -<% end %> - diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml new file mode 100644 index 000000000..3e2668d01 --- /dev/null +++ b/app/views/user/show.rhtml @@ -0,0 +1,21 @@ +<% @title = h(@display_users[0].name) %> + +<% if (@display_users.size > 1) %> +

There is more than one user with this name. +<% end%> + +<% for display_user in @display_users %> +

<%=@title%>

+

Joined on <%= simple_date(display_user.created_at) %>

+ +

Freedom of Information requests made by this person:

+ +<% end %> + diff --git a/config/routes.rb b/config/routes.rb index 7d4e0c3f0..5c5cc905b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: routes.rb,v 1.15 2007-10-16 21:17:15 louise Exp $ +# $Id: routes.rb,v 1.16 2007-10-30 14:49:08 francis Exp $ ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. @@ -25,7 +25,7 @@ ActionController::Routing::Routes.draw do |map| user.signin '/signin', :action => 'signin' user.signup '/signup', :action => 'signup' user.signout '/signout', :action => 'signout' - user.show_user "/user/:name", :action => 'index' + user.show_user "/user/:name", :action => 'show' end map.public_body "/body/:short_name", :controller => 'body', :action => 'show' @@ -47,6 +47,7 @@ ActionController::Routing::Routes.draw do |map| # Install the default route as the lowest priority. # FAI: Turned off for now, as to be honest I don't trust it from a security point of view. + # Somebody is bound to leave a method public in a controller that shouldn't be. #map.connect ':controller/:action/:id.:format' #map.connect ':controller/:action/:id' # map.connect '/:controller/:action' diff --git a/todo.txt b/todo.txt index 64429e7cf..6e17e67d7 100644 --- a/todo.txt +++ b/todo.txt @@ -2,9 +2,6 @@ Send confirmation email Make it say "dear" as default letter -Make sure index for every controller shows all, and the /controller/:id URLs go to a show action -so body/index.rhtml should go? and request/index.rhtml should be show.rhtml? - Escape/simplify short name properly in URLs of public bodies For public bodies whose short names are renamed, make old URL still work and redirect -- cgit v1.2.3