From e74273d496b05c4c951c88195b76cdf505309425 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 6 Jan 2025 17:42:51 +0300 Subject: [PATCH] Add ElementsController base class --- app/controllers/elements_controller.rb | 12 ++++++++++++ app/controllers/nodes_controller.rb | 13 +------------ app/controllers/relations_controller.rb | 13 +------------ app/controllers/ways_controller.rb | 13 +------------ 4 files changed, 15 insertions(+), 36 deletions(-) create mode 100644 app/controllers/elements_controller.rb diff --git a/app/controllers/elements_controller.rb b/app/controllers/elements_controller.rb new file mode 100644 index 000000000..99c8afe3b --- /dev/null +++ b/app/controllers/elements_controller.rb @@ -0,0 +1,12 @@ +class ElementsController < 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 +end diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index a05fa8cd2..7469b8a86 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb @@ -1,15 +1,4 @@ -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 - +class NodesController < ElementsController def show @type = "node" @feature = Node.preload(:node_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :ways => :way_tags).find(params[:id]) diff --git a/app/controllers/relations_controller.rb b/app/controllers/relations_controller.rb index 8aeefd6cc..06ee785f0 100644 --- a/app/controllers/relations_controller.rb +++ b/app/controllers/relations_controller.rb @@ -1,15 +1,4 @@ -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 - +class RelationsController < ElementsController def show @type = "relation" @feature = Relation.preload(:relation_tags, :containing_relation_members, :changeset => [:changeset_tags, :user], :relation_members => :member).find(params[:id]) diff --git a/app/controllers/ways_controller.rb b/app/controllers/ways_controller.rb index d4abe2db7..bf45cca63 100644 --- a/app/controllers/ways_controller.rb +++ b/app/controllers/ways_controller.rb @@ -1,15 +1,4 @@ -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 - +class WaysController < ElementsController 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]) -- 2.39.5