Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queries and keys controllers in features namespace #5024

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/abilities/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ class Ability
include CanCan::Ability

def initialize(user)
can :query, :browse
can :read, [:feature_query, :feature_key]
can :read, [Node, Way, Relation, OldNode, OldWay, OldRelation]
can [:show, :create], Note
can :search, :direction
can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site
can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :id], :site
can [:finish, :embed], :export
can [:search, :search_latlon, :search_osm_nominatim, :search_osm_nominatim_reverse], :geocoder

Expand Down
13 changes: 0 additions & 13 deletions app/controllers/browse_controller.rb

This file was deleted.

21 changes: 21 additions & 0 deletions app/controllers/features/keys_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Features
class KeysController < ApplicationController
before_action :authorize_web
before_action :set_locale

authorize_resource :class => :feature_key

def show
expires_in 7.days, :public => true
@key = YAML.load_file(Rails.root.join("config/key.yml"))
@key.each_value do |layer_data|
layer_data.each do |entry|
entry["name"] = Array(entry["name"])
end
layer_data.each_cons(2) do |entry, next_entry|
entry["max_zoom"] = next_entry["min_zoom"] - 1 if entry["name"] == next_entry["name"] && !entry["max_zoom"] && next_entry["min_zoom"]
end
end
end
end
end
15 changes: 15 additions & 0 deletions app/controllers/features/queries_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Features
class QueriesController < ApplicationController
layout :map_layout

before_action :authorize_web
before_action :set_locale
before_action -> { check_database_readable(:need_api => true) }
before_action :require_oauth
before_action :update_totp
around_action :web_timeout
authorize_resource :class => :feature_query

def show; end
end
end
14 changes: 0 additions & 14 deletions app/controllers/site_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,6 @@ def permalink
redirect_to path
end

def key
expires_in 7.days, :public => true
@key = YAML.load_file(Rails.root.join("config/key.yml"))
@key.each_value do |layer_data|
layer_data.each do |entry|
entry["name"] = Array(entry["name"])
end
layer_data.each_cons(2) do |entry, next_entry|
entry["max_zoom"] = next_entry["min_zoom"] - 1 if entry["name"] == next_entry["name"] && !entry["max_zoom"] && next_entry["min_zoom"]
end
end
render :layout => false
end

def edit
editor = preferred_editor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<% end %>
</td>
<td>
<%= entry["name"].map { |feature_name| t ".table.entry.#{feature_name}" }.join(" · ") %>
<%= entry["name"].map { |feature_name| t ".entries.#{feature_name}" }.join(" · ") %>
</td>
<% end %>
<% end %>
Expand Down
190 changes: 96 additions & 94 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,102 @@ en:
telephone_link: "Call %{phone_number}"
colour_preview: "Colour %{colour_value} preview"
email_link: "Email %{email}"
query:
title: "Query Features"
introduction: "Click on the map to find nearby features."
nearby: "Nearby features"
enclosing: "Enclosing features"
features:
keys:
show:
entries:
motorway: "Motorway"
main_road: "Main road"
trunk: "Trunk road"
primary: "Primary road"
secondary: "Secondary road"
unclassified: "Unclassified road"
pedestrian: "Pedestrian way"
track: "Track"
bridleway: "Bridleway"
cycleway: "Cycleway"
cycleway_national: "National cycleway"
cycleway_regional: "Regional cycleway"
cycleway_local: "Local cycleway"
cycleway_mtb: "Mountain bike route"
footway: "Footway"
rail: "Railway"
train: "Train"
subway: "Subway"
ferry: "Ferry"
light_rail: "Light rail"
tram: "Tram"
trolleybus: "Trolleybus"
bus: "Bus"
cable_car: "Cable car"
chair_lift: "Chair lift"
runway: "Airport Runway"
taxiway: "Taxiway"
apron: "Airport apron"
admin: "Administrative boundary"
capital: "Capital"
city: "City"
orchard: "Orchard"
vineyard: "Vineyard"
forest: "Forest"
wood: "Wood"
farmland: "Farmland"
grass: "Grass"
meadow: "Meadow"
bare_rock: "Bare rock"
sand: "Sand"
golf: "Golf course"
park: "Park"
common: "Common"
built_up: "Built-up area"
resident: "Residential area"
retail: "Retail area"
industrial: "Industrial area"
commercial: "Commercial area"
heathland: "Heathland"
scrubland: "Scrubland"
lake: "Lake"
reservoir: "Reservoir"
intermittent_water: "Intermittent waterbody"
glacier: "Glacier"
reef: "Reef"
wetland: "Wetland"
farm: "Farm"
brownfield: "Brownfield site"
cemetery: "Cemetery"
allotments: "Allotments"
pitch: "Sports pitch"
centre: "Sports centre"
beach: "Beach"
reserve: "Nature reserve"
military: "Military area"
school: "School"
university: "University"
hospital: "Hospital"
building: "Significant building"
station: "Railway station"
railway_halt: "Railway halt"
subway_station: "Subway station"
tram_stop: "Tram stop"
summit: "Summit"
peak: "Peak"
tunnel: "Dashed casing = tunnel"
bridge: "Black casing = bridge"
private: "Private access"
destination: "Destination access"
construction: "Roads under construction"
bus_stop: "Bus stop"
bicycle_shop: "Bicycle shop"
bicycle_rental: "Bicycle rental"
bicycle_parking: "Bicycle parking"
bicycle_parking_small: "Small bicycle parking"
toilets: "Toilets"
queries:
show:
title: "Query Features"
introduction: "Click on the map to find nearby features."
nearby: "Nearby features"
enclosing: "Enclosing features"
nodes:
timeout:
sorry: "Sorry, the data for the node with the id %{id} took too long to retrieve."
Expand Down Expand Up @@ -2334,95 +2425,6 @@ en:
where_am_i_title: Describe the current location using the search engine
submit_text: "Go"
reverse_directions_text: "Reverse Directions"
key:
table:
entry:
motorway: "Motorway"
main_road: "Main road"
trunk: "Trunk road"
primary: "Primary road"
secondary: "Secondary road"
unclassified: "Unclassified road"
pedestrian: "Pedestrian way"
track: "Track"
bridleway: "Bridleway"
cycleway: "Cycleway"
cycleway_national: "National cycleway"
cycleway_regional: "Regional cycleway"
cycleway_local: "Local cycleway"
cycleway_mtb: "Mountain bike route"
footway: "Footway"
rail: "Railway"
train: "Train"
subway: "Subway"
ferry: "Ferry"
light_rail: "Light rail"
tram: "Tram"
trolleybus: "Trolleybus"
bus: "Bus"
cable_car: "Cable car"
chair_lift: "Chair lift"
runway: "Airport Runway"
taxiway: "Taxiway"
apron: "Airport apron"
admin: "Administrative boundary"
capital: "Capital"
city: "City"
orchard: "Orchard"
vineyard: "Vineyard"
forest: "Forest"
wood: "Wood"
farmland: "Farmland"
grass: "Grass"
meadow: "Meadow"
bare_rock: "Bare rock"
sand: "Sand"
golf: "Golf course"
park: "Park"
common: "Common"
built_up: "Built-up area"
resident: "Residential area"
retail: "Retail area"
industrial: "Industrial area"
commercial: "Commercial area"
heathland: "Heathland"
scrubland: "Scrubland"
lake: "Lake"
reservoir: "Reservoir"
intermittent_water: "Intermittent waterbody"
glacier: "Glacier"
reef: "Reef"
wetland: "Wetland"
farm: "Farm"
brownfield: "Brownfield site"
cemetery: "Cemetery"
allotments: "Allotments"
pitch: "Sports pitch"
centre: "Sports centre"
beach: "Beach"
reserve: "Nature reserve"
military: "Military area"
school: "School"
university: "University"
hospital: "Hospital"
building: "Significant building"
station: "Railway station"
railway_halt: "Railway halt"
subway_station: "Subway station"
tram_stop: "Tram stop"
summit: "Summit"
peak: "Peak"
tunnel: "Dashed casing = tunnel"
bridge: "Black casing = bridge"
private: "Private access"
destination: "Destination access"
construction: "Roads under construction"
bus_stop: "Bus stop"
bicycle_shop: "Bicycle shop"
bicycle_rental: "Bicycle rental"
bicycle_parking: "Bicycle parking"
bicycle_parking_small: "Small bicycle parking"
toilets: "Toilets"
welcome:
title: Welcome!
introduction: |
Expand Down
6 changes: 4 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@
post "/login" => "sessions#create"
match "/logout" => "sessions#destroy", :via => [:get, :post]
get "/offline" => "site#offline"
get "/key" => "site#key"
get "/id" => "site#id"
get "/query" => "browse#query"
namespace :features, :path => "" do
resource :key, :only => :show
resource :query, :only => :show
end
get "/user/new" => "users#new"
post "/user/new" => "users#create"
get "/user/terms" => "users#terms"
Expand Down
18 changes: 0 additions & 18 deletions test/controllers/browse_controller_test.rb

This file was deleted.

22 changes: 22 additions & 0 deletions test/controllers/features/keys_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require "test_helper"

module Features
class KeysControllerTest < ActionDispatch::IntegrationTest
##
# test all routes which lead to this controller
def test_routes
assert_routing(
{ :path => "/key", :method => :get },
{ :controller => "features/keys", :action => "show" }
)
end

def test_show
get features_key_path, :xhr => true

assert_response :success
assert_template "features/keys/show"
assert_template :layout => false
end
end
end
21 changes: 21 additions & 0 deletions test/controllers/features/queries_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "test_helper"

module Features
class QueriesControllerTest < ActionDispatch::IntegrationTest
##
# test all routes which lead to this controller
def test_routes
assert_routing(
{ :path => "/query", :method => :get },
{ :controller => "features/queries", :action => "show" }
)
end

def test_show
get features_query_path

assert_response :success
assert_template "features/queries/show"
end
end
end
Loading
Loading