aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application.rb4
-rw-r--r--app/controllers/body_controller.rb12
-rw-r--r--app/controllers/user_controller.rb6
3 files changed, 11 insertions, 11 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 83c606ad2..f518a89e9 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: application.rb,v 1.28 2008-01-29 03:05:46 francis Exp $
+# $Id: application.rb,v 1.29 2008-02-27 12:04:10 francis Exp $
class ApplicationController < ActionController::Base
@@ -44,7 +44,7 @@ class ApplicationController < ActionController::Base
def authenticated_as_user?(user, reason_params)
reason_params[:user_name] = user.name
- reason_params[:user_url] = show_user_url(:simple_name => simplify_url_part(user.name))
+ reason_params[:user_url] = show_user_url(:simple_name => MySociety::Format.simplify_url_part(user.name))
if session[:user_id]
if session[:user_id] == user.id
# They are logged in as the right user
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb
index 7f2d1fe05..a557c0cfc 100644
--- a/app/controllers/body_controller.rb
+++ b/app/controllers/body_controller.rb
@@ -4,27 +4,27 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: body_controller.rb,v 1.4 2008-02-22 13:49:37 francis Exp $
+# $Id: body_controller.rb,v 1.5 2008-02-27 12:04:10 francis Exp $
class BodyController < ApplicationController
# XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL
def show
@public_bodies = PublicBody.find(:all,
- :conditions => [ "regexp_replace(replace(lower(short_name), ' ', '-'), '[^a-z0-9_-]', '', 'g') = ?", params[:simple_short_name] ])
+ :conditions => [ "url_name = ?", params[:simple_short_name] ])
if @public_bodies.size > 1
- raise "Two bodies with the same simplified short name: " . params[:simple_short_name]
+ raise "Two bodies with the same URL name: " . params[:simple_short_name]
end
# If none found, then search the history of short names, and do a redirect
if @public_bodies.size == 0
@public_bodies = PublicBody.find(:all,
- :conditions => [ "id in (select public_body_id from public_body_versions where regexp_replace(replace(lower(short_name), ' ', '-'), '[^a-z0-9_-]', '', 'g') = ?)", params[:simple_short_name] ])
+ :conditions => [ "id in (select public_body_id from public_body_versions where url_name = ?)", params[:simple_short_name] ])
if @public_bodies.size > 1
- raise "Two bodies with the same historical simplified short name: " . params[:simple_short_name]
+ raise "Two bodies with the same historical URL name: " . params[:simple_short_name]
end
if @public_bodies.size == 0
raise "None found" # XXX proper 404
end
- redirect_to show_public_body_url(:simple_short_name => simplify_url_part(@public_bodies[0].short_name))
+ redirect_to show_public_body_url(:simple_short_name => @public_bodies[0].url_name)
end
@public_body = @public_bodies[0]
end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index baeffc7db..8dc056167 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -4,13 +4,13 @@
# 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.26 2008-02-20 12:51:29 francis Exp $
+# $Id: user_controller.rb,v 1.27 2008-02-27 12:04:10 francis Exp $
class UserController < ApplicationController
# XXX See controllers/application.rb simplify_url_part for reverse of expression in SQL below
def show
- if simplify_url_part(params[:simple_name]) != params[:simple_name]
- redirect_to :simple_name => simplify_url_part(params[:simple_name])
+ if MySociety::Format.simplify_url_part(params[:simple_name]) != params[:simple_name]
+ redirect_to :simple_name => MySociety::Format.simplify_url_part(params[:simple_name])
end
@display_users = User.find(:all, :conditions => [ "regexp_replace(replace(lower(name), ' ', '-'), '[^a-z0-9_-]', '', 'g') = ?", params[:simple_name] ], :order => "created_at desc")