From 734cbb967de8e04f15e01ee2103033064dd290d4 Mon Sep 17 00:00:00 2001 From: Shaun McDonald Date: Mon, 13 Oct 2008 12:08:26 +0000 Subject: [PATCH 1/1] fixing the data browser to be able to cope with the changeset change. changeset browsing still needs to be implemented. Also giving a nice error message for 404 not found instead of rendering nothing. --- app/controllers/browse_controller.rb | 30 +++++++++++++++----------- app/views/browse/_common_details.rhtml | 4 ++-- app/views/browse/not_found.rhtml | 1 + 3 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 app/views/browse/not_found.rhtml diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb index f3a04519c..408846c96 100644 --- a/app/controllers/browse_controller.rb +++ b/app/controllers/browse_controller.rb @@ -17,14 +17,15 @@ class BrowseController < ApplicationController @name = @relation.tags['name'].to_s if @name.length == 0: - @name = "#" + @relation.id.to_s + @name = "#" + @relation.id.to_s end @title = 'Relation | ' + (@name) @next = Relation.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @relation.id }] ) @prev = Relation.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @relation.id }] ) rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + @type = "relation" + render :action => "not_found", :status => :not_found end end @@ -34,12 +35,13 @@ class BrowseController < ApplicationController @name = @relation.tags['name'].to_s if @name.length == 0: - @name = "#" + @relation.id.to_s + @name = "#" + @relation.id.to_s end @title = 'Relation History | ' + (@name) rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + @type = "relation" + render :action => "not_found", :status => :not_found end end @@ -49,14 +51,15 @@ class BrowseController < ApplicationController @name = @way.tags['name'].to_s if @name.length == 0: - @name = "#" + @way.id.to_s + @name = "#" + @way.id.to_s end @title = 'Way | ' + (@name) @next = Way.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @way.id }] ) @prev = Way.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @way.id }] ) rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + @type = "way" + render :action => "not_found", :status => :not_found end end @@ -66,12 +69,13 @@ class BrowseController < ApplicationController @name = @way.tags['name'].to_s if @name.length == 0: - @name = "#" + @way.id.to_s + @name = "#" + @way.id.to_s end @title = 'Way History | ' + (@name) rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + @type = "way" + render :action => "not_found", :status => :not_found end end @@ -81,14 +85,15 @@ class BrowseController < ApplicationController @name = @node.tags_as_hash['name'].to_s if @name.length == 0: - @name = "#" + @node.id.to_s + @name = "#" + @node.id.to_s end @title = 'Node | ' + (@name) @next = Node.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @node.id }] ) @prev = Node.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @node.id }] ) rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + @type = "node" + render :action => "not_found", :status => :not_found end end @@ -98,12 +103,13 @@ class BrowseController < ApplicationController @name = @node.tags_as_hash['name'].to_s if @name.length == 0: - @name = "#" + @node.id.to_s + @name = "#" + @node.id.to_s end @title = 'Node History | ' + (@name) rescue ActiveRecord::RecordNotFound - render :nothing => true, :status => :not_found + @type = "way" + render :action => "not_found", :status => :not_found end end end diff --git a/app/views/browse/_common_details.rhtml b/app/views/browse/_common_details.rhtml index ee5f22cee..d7b340e9d 100644 --- a/app/views/browse/_common_details.rhtml +++ b/app/views/browse/_common_details.rhtml @@ -3,10 +3,10 @@ <%= h(common_details.timestamp) %> -<% if common_details.user.data_public %> +<% if common_details.changeset.user.data_public %> Edited by: - <%= link_to h(common_details.user.display_name), :controller => "user", :action => "view", :display_name => common_details.user.display_name %> + <%= link_to h(common_details.changeset.user.display_name), :controller => "user", :action => "view", :display_name => common_details.changeset.user.display_name %> <% end %> diff --git a/app/views/browse/not_found.rhtml b/app/views/browse/not_found.rhtml new file mode 100644 index 000000000..1322a0a6f --- /dev/null +++ b/app/views/browse/not_found.rhtml @@ -0,0 +1 @@ +

Sorry, the <%= @type -%> with the id <%= params[:id] -%>, could not be found.

-- 2.43.2