Merge remote-tracking branch 'upstream/pull/4579'
This commit is contained in:
commit
5b916792cc
16 changed files with 224 additions and 171 deletions
|
@ -4,7 +4,8 @@ class Ability
|
|||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
can [:relation, :way, :node, :query], :browse
|
||||
can :query, :browse
|
||||
can :show, [Node, Way, Relation]
|
||||
can [:index, :show], [OldNode, OldWay, OldRelation]
|
||||
can [:show, :new], Note
|
||||
can :search, :direction
|
||||
|
|
|
@ -9,29 +9,5 @@ class BrowseController < ApplicationController
|
|||
around_action :web_timeout
|
||||
authorize_resource :class => false
|
||||
|
||||
def relation
|
||||
@type = "relation"
|
||||
@feature = Relation.preload(:relation_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :relation_members => :member).find(params[:id])
|
||||
render "feature"
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
def way
|
||||
@type = "way"
|
||||
@feature = Way.preload(:way_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :nodes => [:node_tags, { :ways => :way_tags }]).find(params[:id])
|
||||
render "feature"
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
def node
|
||||
@type = "node"
|
||||
@feature = Node.preload(:node_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :ways => :way_tags).find(params[:id])
|
||||
render "feature"
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
def query; end
|
||||
end
|
||||
|
|
20
app/controllers/nodes_controller.rb
Normal file
20
app/controllers/nodes_controller.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class NodesController < ApplicationController
|
||||
layout :map_layout
|
||||
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action -> { check_database_readable(:need_api => true) }
|
||||
before_action :require_oauth
|
||||
|
||||
authorize_resource
|
||||
|
||||
around_action :web_timeout
|
||||
|
||||
def show
|
||||
@type = "node"
|
||||
@feature = Node.preload(:node_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :ways => :way_tags).find(params[:id])
|
||||
render "browse/feature"
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render "browse/not_found", :status => :not_found
|
||||
end
|
||||
end
|
20
app/controllers/relations_controller.rb
Normal file
20
app/controllers/relations_controller.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class RelationsController < ApplicationController
|
||||
layout :map_layout
|
||||
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action -> { check_database_readable(:need_api => true) }
|
||||
before_action :require_oauth
|
||||
|
||||
authorize_resource
|
||||
|
||||
around_action :web_timeout
|
||||
|
||||
def show
|
||||
@type = "relation"
|
||||
@feature = Relation.preload(:relation_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :relation_members => :member).find(params[:id])
|
||||
render "browse/feature"
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render "browse/not_found", :status => :not_found
|
||||
end
|
||||
end
|
20
app/controllers/ways_controller.rb
Normal file
20
app/controllers/ways_controller.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class WaysController < ApplicationController
|
||||
layout :map_layout
|
||||
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action -> { check_database_readable(:need_api => true) }
|
||||
before_action :require_oauth
|
||||
|
||||
authorize_resource
|
||||
|
||||
around_action :web_timeout
|
||||
|
||||
def show
|
||||
@type = "way"
|
||||
@feature = Way.preload(:way_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :nodes => [:node_tags, { :ways => :way_tags }]).find(params[:id])
|
||||
render "browse/feature"
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render "browse/not_found", :status => :not_found
|
||||
end
|
||||
end
|
|
@ -3,7 +3,7 @@ module GeocoderHelper
|
|||
html_options = { :class => "set_position stretched-link", :data => {} }
|
||||
|
||||
url = if result[:type] && result[:id]
|
||||
url_for(:controller => :browse, :action => result[:type], :id => result[:id])
|
||||
url_for(:controller => result[:type].pluralize, :action => :show, :id => result[:id])
|
||||
elsif result[:min_lon] && result[:min_lat] && result[:max_lon] && result[:max_lat]
|
||||
"/?bbox=#{result[:min_lon]},#{result[:min_lat]},#{result[:max_lon]},#{result[:max_lat]}"
|
||||
else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% linked_name = link_to printable_element_name(relation_member.member), { :controller => :browse, :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, { :rel => link_follow(relation_member.member) }
|
||||
<% linked_name = link_to printable_element_name(relation_member.member), { :controller => relation_member.member_type.downcase.pluralize, :action => :show, :id => relation_member.member_id.to_s }, { :rel => link_follow(relation_member.member) }
|
||||
type_str = t ".type.#{relation_member.member_type.downcase}" %>
|
||||
<%= element_list_item relation_member.member_type.downcase, relation_member.member do %>
|
||||
<%= if relation_member.member_role.blank?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class='secondary-actions'>
|
||||
<%= link_to t("browse.view_details"), :controller => :browse, :action => @type %>
|
||||
<%= link_to t("browse.view_details"), :controller => @type.pluralize, :action => :show %>
|
||||
<% if !@feature.redacted? %>
|
||||
·
|
||||
<%= link_to t("browse.download_xml"), :controller => "api/old_#{@type.pluralize}", :action => :show %>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<%= render "sidebar_header", :title => t("browse.#{@type}.title_html", :name => printable_element_name(@feature)) %>
|
||||
|
||||
<%= render :partial => @type, :object => @feature %>
|
||||
<%= render :partial => "browse/#{@type}", :object => @feature %>
|
||||
|
||||
<% if @feature.visible? %>
|
||||
<div class='secondary-actions'>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class='secondary-actions'>
|
||||
<%= link_to t("browse.download_xml"), :controller => "api/old_#{@type.pluralize}", :action => "history" %>
|
||||
·
|
||||
<%= link_to t("browse.view_details"), :controller => "browse", :action => @type %>
|
||||
<%= link_to t("browse.view_details"), :controller => @type.pluralize, :action => :show %>
|
||||
<% if params[:show_redactions] %>
|
||||
·
|
||||
<%= link_to t("browse.view_history") %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue