diff options
Diffstat (limited to 'app/controllers/public_body_controller.rb')
-rw-r--r-- | app/controllers/public_body_controller.rb | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index e31b52f9d..c74959b17 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -20,11 +20,16 @@ class PublicBodyController < ApplicationController PublicBody.with_locale(@locale) do @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) raise "None found" if @public_body.nil? # XXX proper 404 - return redirect_to :back if @public_body.url_name.nil? - # If found by historic name, redirect to new name - redirect_to show_public_body_url(:url_name => @public_body.url_name) if - @public_body.url_name != params[:url_name] - + if @public_body.url_name.nil? + redirect_to :back + return + end + # If found by historic name, or alternate locale name, redirect to new name + if @public_body.url_name != params[:url_name] + redirect_to show_public_body_url(:url_name => @public_body.url_name) + return + end + set_last_body(@public_body) top_url = main_url("/") @@ -51,9 +56,10 @@ class PublicBodyController < ApplicationController @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] respond_to do |format| - format.html { @has_json = true } + format.html { @has_json = true; render :template => "public_body/show"} format.json { render :json => @public_body.json_for_api } end + end end @@ -99,13 +105,6 @@ class PublicBodyController < ApplicationController and has_tag_string_tags.model = \'PublicBody\' and has_tag_string_tags.name = ?) > 0', @locale, @tag] end - PublicBody.with_locale(@locale) do - @public_bodies = PublicBody.paginate( - :order => "public_body_translations.name", :page => params[:page], :per_page => 1000, # fit all councils on one page - :conditions => conditions, - :joins => :translations - ) - end if @tag.size == 1 @description = _("beginning with") + " '" + @tag + "'" else @@ -114,6 +113,14 @@ class PublicBodyController < ApplicationController @description = @tag end end + PublicBody.with_locale(@locale) do + @public_bodies = PublicBody.paginate( + :order => "public_body_translations.name", :page => params[:page], :per_page => 1000, # fit all councils on one page + :conditions => conditions, + :joins => :translations + ) + render :template => "public_body/list" + end end # Used so URLs like /local/islington work, for use e.g. writing to a local paper. |