diff --git a/app/assets/javascripts/map.js b/app/assets/javascripts/map.js
index a0f5bd7c6..d0b47aa58 100644
--- a/app/assets/javascripts/map.js
+++ b/app/assets/javascripts/map.js
@@ -6,11 +6,6 @@
$("*[data-map]:visible").each(function() {
App.Map.initializeMap(this);
});
- $(".js-toggle-map").on({
- click: function() {
- App.Map.toggleMap();
- }
- });
},
destroy: function() {
App.Map.maps.forEach(function(map) {
@@ -149,10 +144,6 @@
});
}
},
- toggleMap: function() {
- $(".map").toggle();
- $(".js-location-map-remove-marker").toggle();
- },
cleanInvestmentCoordinates: function(element) {
var clean_markers, markers;
markers = $(element).attr("data-marker-investments-coordinates");
diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb
index a5931cf24..b30d230ff 100644
--- a/app/controllers/budgets/investments_controller.rb
+++ b/app/controllers/budgets/investments_controller.rb
@@ -135,7 +135,7 @@ module Budgets
def investment_params
attributes = [:heading_id, :tag_list, :organization_name, :location,
- :terms_of_service, :skip_map, :related_sdg_list,
+ :terms_of_service, :related_sdg_list,
image_attributes: image_attributes,
documents_attributes: document_attributes,
map_location_attributes: map_location_attributes]
diff --git a/app/controllers/management/budgets/investments_controller.rb b/app/controllers/management/budgets/investments_controller.rb
index d612317a7..537c1bc70 100644
--- a/app/controllers/management/budgets/investments_controller.rb
+++ b/app/controllers/management/budgets/investments_controller.rb
@@ -60,7 +60,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController
end
def investment_params
- attributes = [:external_url, :heading_id, :tag_list, :organization_name, :location, :skip_map,
+ attributes = [:external_url, :heading_id, :tag_list, :organization_name, :location,
image_attributes: image_attributes,
documents_attributes: document_attributes,
map_location_attributes: map_location_attributes]
diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb
index 2e7cd1aca..a384bb541 100644
--- a/app/controllers/management/proposals_controller.rb
+++ b/app/controllers/management/proposals_controller.rb
@@ -57,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: map_location_attributes]
+ 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 d99a402cd..fc0b977df 100644
--- a/app/controllers/proposals_controller.rb
+++ b/app/controllers/proposals_controller.rb
@@ -101,7 +101,7 @@ class ProposalsController < ApplicationController
def proposal_params
attributes = [:video_url, :responsible_name, :tag_list, :terms_of_service,
- :geozone_id, :skip_map, :related_sdg_list,
+ :geozone_id, :related_sdg_list,
image_attributes: image_attributes,
documents_attributes: document_attributes,
map_location_attributes: map_location_attributes]
diff --git a/app/models/concerns/mappable.rb b/app/models/concerns/mappable.rb
index a565fb199..4b2dbbb53 100644
--- a/app/models/concerns/mappable.rb
+++ b/app/models/concerns/mappable.rb
@@ -2,28 +2,11 @@ module Mappable
extend ActiveSupport::Concern
included do
- attr_accessor :skip_map
-
has_one :map_location, dependent: :destroy
accepts_nested_attributes_for :map_location, allow_destroy: true, reject_if: :all_blank
- validate :map_must_be_valid, on: :create, if: :feature_maps?
-
- def map_must_be_valid
- return true if skip_map?
-
- unless map_location&.available?
- skip_map_error = I18n.t("activerecord.errors.models.map_location.attributes.map.invalid")
- errors.add(:skip_map, skip_map_error)
- end
- end
-
def feature_maps?
Setting["feature.map"].present?
end
-
- def skip_map?
- skip_map == "1"
- end
end
end
diff --git a/app/views/map_locations/_form_fields.html.erb b/app/views/map_locations/_form_fields.html.erb
index 132c39a00..f2690693c 100644
--- a/app/views/map_locations/_form_fields.html.erb
+++ b/app/views/map_locations/_form_fields.html.erb
@@ -16,10 +16,4 @@
<%= m_l_fields.hidden_field :zoom,
value: map_location.zoom,
id: map_location_input_id(parent_class, "zoom") %>
-
-
- <%= form.check_box :skip_map,
- label: t("#{i18n_namespace}.form.map_skip_checkbox"),
- class: "js-toggle-map" %>
-
<% end %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index a00013b70..802b5179a 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -536,10 +536,6 @@ en:
attributes:
segment_recipient:
invalid: "The user recipients segment is invalid"
- map_location:
- attributes:
- map:
- invalid: Map location can't be blank. Place a marker or select the checkbox if geolocalization is not needed
poll/voter:
attributes:
document_number:
diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml
index 7a15ba14e..67bb1ab26 100644
--- a/config/locales/en/budgets.yml
+++ b/config/locales/en/budgets.yml
@@ -85,7 +85,6 @@ en:
map_location: "Map location"
map_location_instructions: "Navigate the map to the location and place the marker."
map_remove_marker: "Remove map marker"
- map_skip_checkbox: "This investment doesn't have a concrete location or I'm not aware of it."
index:
title: Participatory budgeting
unfeasible: Unfeasible investment projects
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index 20521fa3b..969704fa3 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -347,7 +347,6 @@ en:
map_location: "Map location"
map_location_instructions: "Navigate the map to the location and place the marker."
map_remove_marker: "Remove map marker"
- map_skip_checkbox: "This proposal doesn't have a concrete location or I'm not aware of it."
index:
featured_proposals: Featured
orders:
diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml
index 35f62237e..cef90c618 100644
--- a/config/locales/es/activerecord.yml
+++ b/config/locales/es/activerecord.yml
@@ -536,10 +536,6 @@ es:
attributes:
segment_recipient:
invalid: "El usuario del destinatario es inválido"
- map_location:
- attributes:
- map:
- invalid: El mapa no puede estar en blanco. Añade un punto al mapa o marca la casilla si no hace falta un mapa.
poll/voter:
attributes:
document_number:
diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml
index 4daa54c58..03bacc0e5 100644
--- a/config/locales/es/budgets.yml
+++ b/config/locales/es/budgets.yml
@@ -85,7 +85,6 @@ es:
map_location: "Ubicación en el mapa"
map_location_instructions: "Navega por el mapa hasta la ubicación y coloca el marcador."
map_remove_marker: "Eliminar el marcador"
- map_skip_checkbox: "Este proyecto no tiene una ubicación concreta o no la conozco."
index:
title: Presupuestos participativos
unfeasible: Proyectos de gasto no viables
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index 58ae6f333..9bb9618e0 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -347,7 +347,6 @@ es:
map_location: "Ubicación en el mapa"
map_location_instructions: "Navega por el mapa hasta la ubicación y coloca el marcador."
map_remove_marker: "Eliminar el marcador"
- map_skip_checkbox: "Esta propuesta no tiene una ubicación concreta o no la conozco."
index:
featured_proposals: Destacadas
orders:
diff --git a/db/dev_seeds/budgets.rb b/db/dev_seeds/budgets.rb
index 59657a4b5..9c803af32 100644
--- a/db/dev_seeds/budgets.rb
+++ b/db/dev_seeds/budgets.rb
@@ -140,7 +140,6 @@ section "Creating Investments" do
valuation_finished: [false, true].sample,
tag_list: tags.sample(3).join(","),
price: rand(1..100) * 100000,
- skip_map: "1",
terms_of_service: "1"
}.merge(translation_attributes))
@@ -187,7 +186,6 @@ section "Winner Investments" do
valuation_finished: true,
selected: true,
price: rand(10000..heading.price),
- skip_map: "1",
terms_of_service: "1"
)
add_image_to(investment) if Random.rand > 0.3
diff --git a/db/dev_seeds/proposals.rb b/db/dev_seeds/proposals.rb
index e825f240c..31675c023 100644
--- a/db/dev_seeds/proposals.rb
+++ b/db/dev_seeds/proposals.rb
@@ -37,7 +37,6 @@ section "Creating Proposals" do
created_at: rand((Time.current - 1.week)..Time.current),
tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample,
- skip_map: "1",
terms_of_service: "1",
published_at: Time.current)
random_locales.map do |locale|
@@ -65,7 +64,6 @@ section "Creating Archived Proposals" do
description: description,
tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample,
- skip_map: "1",
terms_of_service: "1",
created_at: months_to_archive_proposals.to_i.months.ago,
published_at: months_to_archive_proposals.to_i.months.ago)
@@ -94,7 +92,6 @@ section "Creating Successful Proposals" do
created_at: rand((Time.current - 1.week)..Time.current),
tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample,
- skip_map: "1",
terms_of_service: "1",
cached_votes_up: Setting["votes_for_proposal_success"],
published_at: Time.current)
@@ -121,7 +118,6 @@ section "Creating Successful Proposals" do
created_at: rand((Time.current - 1.week)..Time.current),
tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample,
- skip_map: "1",
terms_of_service: "1",
published_at: Time.current)
random_locales.map do |locale|
diff --git a/lib/tasks/proposal_actions.rake b/lib/tasks/proposal_actions.rake
index f3897c7ea..8dfc3d245 100644
--- a/lib/tasks/proposal_actions.rake
+++ b/lib/tasks/proposal_actions.rake
@@ -398,7 +398,6 @@ namespace :proposal_actions do
created_at: Time.current - expected_supports.length.days,
tag_list: "Example",
geozone: Geozone.all.sample,
- skip_map: "1",
terms_of_service: "1",
published_at: Time.current - expected_supports.length.days)
diff --git a/spec/factories/budgets.rb b/spec/factories/budgets.rb
index db9f9c5f0..1c6a371e2 100644
--- a/spec/factories/budgets.rb
+++ b/spec/factories/budgets.rb
@@ -105,7 +105,6 @@ FactoryBot.define do
description { "Spend money on this" }
price { 10 }
unfeasibility_explanation { "" }
- skip_map { "1" }
terms_of_service { "1" }
incompatible { false }
diff --git a/spec/factories/proposals.rb b/spec/factories/proposals.rb
index 7c6df9b46..1398bea22 100644
--- a/spec/factories/proposals.rb
+++ b/spec/factories/proposals.rb
@@ -6,7 +6,6 @@ FactoryBot.define do
video_url { "https://youtu.be/nhuNb0XtRhQ" }
responsible_name { "John Snow" }
terms_of_service { "1" }
- skip_map { "1" }
published_at { Time.current }
association :author, factory: :user
diff --git a/spec/shared/models/map_validations.rb b/spec/shared/models/map_validations.rb
index 5d3e2ee4f..85ad6b29c 100644
--- a/spec/shared/models/map_validations.rb
+++ b/spec/shared/models/map_validations.rb
@@ -8,13 +8,11 @@ shared_examples "map validations" do
it "is valid with a map location" do
mappable.map_location = build(:map_location)
- mappable.skip_map = nil
expect(mappable).to be_valid
end
- it "is valid accepting that the mappable has no map" do
- mappable.skip_map = "1"
+ it "is valid without a location" do
mappable.map_location = nil
expect(mappable).to be_valid
@@ -24,23 +22,9 @@ shared_examples "map validations" do
Setting["feature.map"] = nil
mappable.map_location = nil
- mappable.skip_map = nil
expect(mappable).to be_valid
end
-
- it "is not valid without a map location" do
- mappable.map_location = nil
- mappable.skip_map = nil
-
- expect(mappable).not_to be_valid
- end
-
- it "is not valid without accepting that the mappable has no map" do
- mappable.skip_map = nil
-
- expect(mappable).not_to be_valid
- end
end
describe "cache" do
diff --git a/spec/shared/system/mappable.rb b/spec/shared/system/mappable.rb
index 004ec9dc9..f31ac7108 100644
--- a/spec/shared/system/mappable.rb
+++ b/spec/shared/system/mappable.rb
@@ -54,7 +54,6 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
send("fill_in_#{mappable_factory_name}_form")
expect(page).to have_css ".map_location"
- check "#{mappable_factory_name}_skip_map"
send("submit_#{mappable_factory_name}_form")
expect(page).not_to have_css(".map_location")
@@ -72,15 +71,6 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
expect(page).not_to have_css(".map_location")
end
- scenario "Errors on create" do
- do_login_for user
- visit send(mappable_new_path, arguments)
-
- send("submit_#{mappable_factory_name}_form")
-
- expect(page).to have_content "Map location can't be blank"
- end
-
describe "When restoring the page from browser history" do
before { Setting["org_name"] = "CONSUL" }
@@ -177,26 +167,10 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
visit send(mappable_new_path, arguments)
send("fill_in_#{mappable_factory_name}_form")
- check "#{mappable_factory_name}_skip_map"
send("submit_#{mappable_factory_name}_form")
expect(page).not_to have_content "Map location can't be blank"
end
-
- scenario "Toggle map" do
- do_login_for user
- visit send(mappable_new_path, arguments)
-
- check "#{mappable_factory_name}_skip_map"
-
- expect(page).not_to have_css(".map")
- expect(page).not_to have_content("Remove map marker")
-
- uncheck "#{mappable_factory_name}_skip_map"
-
- expect(page).to have_css(".map")
- expect(page).to have_content("Remove map marker")
- end
end
describe "At #{mappable_edit_path}" do
@@ -242,7 +216,6 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
visit send(mappable_edit_path, id: mappable.id)
click_link "Remove map marker"
- check "#{mappable_factory_name}_skip_map"
click_on "Save changes"
expect(page).not_to have_css(".map_location")