From c1735684048b487222a0210a76d29c86cbb674e7 Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 9 Apr 2021 14:57:18 +0200 Subject: [PATCH] Move map_location attributes to concern --- app/controllers/budgets/investments_controller.rb | 3 ++- app/controllers/concerns/map_location_attributes.rb | 7 +++++++ app/controllers/management/proposals_controller.rb | 3 ++- app/controllers/proposals_controller.rb | 3 ++- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 app/controllers/concerns/map_location_attributes.rb diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index e4ef6ae62..82fbf7f96 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -5,6 +5,7 @@ module Budgets include FlagActions include RandomSeed include ImageAttributes + include MapLocationAttributes include Translatable include InvestmentFilters @@ -136,7 +137,7 @@ module Budgets :terms_of_service, :skip_map, :related_sdg_list, image_attributes: image_attributes, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], - map_location_attributes: [:latitude, :longitude, :zoom]] + map_location_attributes: map_location_attributes] params.require(:budget_investment).permit(attributes, translation_params(Budget::Investment)) end diff --git a/app/controllers/concerns/map_location_attributes.rb b/app/controllers/concerns/map_location_attributes.rb new file mode 100644 index 000000000..5c49d8469 --- /dev/null +++ b/app/controllers/concerns/map_location_attributes.rb @@ -0,0 +1,7 @@ +module MapLocationAttributes + extend ActiveSupport::Concern + + def map_location_attributes + [:latitude, :longitude, :zoom] + end +end diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index 26025b26e..2e7cd1aca 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -2,6 +2,7 @@ class Management::ProposalsController < Management::BaseController include HasOrders include CommentableActions include Translatable + include MapLocationAttributes before_action :only_verified_users, except: :print before_action :set_proposal, only: [:vote, :show] @@ -56,7 +57,7 @@ class Management::ProposalsController < Management::BaseController def proposal_params attributes = [:video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id, - :skip_map, map_location_attributes: [:latitude, :longitude, :zoom]] + :skip_map, map_location_attributes: map_location_attributes] params.require(:proposal).permit(attributes, translation_params(Proposal)) end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 8b28e1f79..c6631198c 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -3,6 +3,7 @@ class ProposalsController < ApplicationController include CommentableActions include FlagActions include ImageAttributes + include MapLocationAttributes include Translatable before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary] @@ -103,7 +104,7 @@ class ProposalsController < ApplicationController image_attributes: image_attributes, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], - map_location_attributes: [:latitude, :longitude, :zoom]] + map_location_attributes: map_location_attributes] translations_attributes = translation_params(Proposal, except: :retired_explanation) params.require(:proposal).permit(attributes, translations_attributes) end