diff --git a/app/controllers/spending_proposals_controller.rb b/app/controllers/spending_proposals_controller.rb
index c182572d3..a7871549f 100644
--- a/app/controllers/spending_proposals_controller.rb
+++ b/app/controllers/spending_proposals_controller.rb
@@ -26,7 +26,7 @@ class SpendingProposalsController < ApplicationController
private
def spending_proposal_params
- params.require(:spending_proposal).permit(:title, :description, :external_url, :terms_of_service, :captcha, :captcha_key)
+ params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :terms_of_service, :captcha, :captcha_key)
end
end
\ No newline at end of file
diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb
index 2f73c2b33..f198bcb57 100644
--- a/app/models/spending_proposal.rb
+++ b/app/models/spending_proposal.rb
@@ -5,6 +5,7 @@ class SpendingProposal < ActiveRecord::Base
apply_simple_captcha
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
+ belongs_to :geozone
validates :title, presence: true
validates :author, presence: true
diff --git a/app/views/spending_proposals/_form.html.erb b/app/views/spending_proposals/_form.html.erb
index 616cee986..39b0e6e0a 100644
--- a/app/views/spending_proposals/_form.html.erb
+++ b/app/views/spending_proposals/_form.html.erb
@@ -17,6 +17,11 @@
<%= f.text_field :external_url, placeholder: t("spending_proposals.form.external_url"), label: false %>
+
+ <%= f.label :geozone_id, t("spending_proposals.form.geozone") %>
+ <%= f.select :geozone_id, Geozone.all.collect { |g| [ g.name, g.id ] }, {include_blank: t("geozones.none"), label: false} %>
+
+
<% if @spending_proposal.new_record? %>
<%= f.label :terms_of_service do %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index f66bba371..0f1284d95 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -263,9 +263,12 @@ en:
title: "Spending proposal title"
description: "Description"
external_url: "Link to additional documentation"
+ geozone: "Area of operation"
submit_buttons:
new: Create
create: Create
+ geozones:
+ none: "All city"
comments:
show:
return_to_commentable: "Go back to "
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 74464cfb4..9d0a07980 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -263,9 +263,12 @@ es:
title: "Título de la propuesta de gasto"
description: "Descripción detallada"
external_url: "Enlace a documentación adicional"
+ geozone: "Nivel de actuación"
submit_buttons:
new: Crear
create: Crear
+ geozones:
+ none: "Toda la ciudad"
comments:
show:
return_to_commentable: "Volver a "
diff --git a/db/migrate/20160107114749_add_geozone_to_spending_proposal.rb b/db/migrate/20160107114749_add_geozone_to_spending_proposal.rb
new file mode 100644
index 000000000..62130fd9b
--- /dev/null
+++ b/db/migrate/20160107114749_add_geozone_to_spending_proposal.rb
@@ -0,0 +1,6 @@
+class AddGeozoneToSpendingProposal < ActiveRecord::Migration
+ def change
+ add_column :spending_proposals, :geozone_id, :integer, default: nil
+ add_index :spending_proposals, :geozone_id
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 95d186822..0d9396440 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -288,9 +288,11 @@ ActiveRecord::Schema.define(version: 20160108133501) do
t.string "external_url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.integer "geozone_id"
end
add_index "spending_proposals", ["author_id"], name: "index_spending_proposals_on_author_id", using: :btree
+ add_index "spending_proposals", ["geozone_id"], name: "index_spending_proposals_on_geozone_id", using: :btree
create_table "taggings", force: :cascade do |t|
t.integer "tag_id"
diff --git a/spec/features/spending_proposals_spec.rb b/spec/features/spending_proposals_spec.rb
index bf4a7f585..65b496fa9 100644
--- a/spec/features/spending_proposals_spec.rb
+++ b/spec/features/spending_proposals_spec.rb
@@ -17,6 +17,7 @@ feature 'Spending proposals' do
fill_in 'spending_proposal_description', with: 'I want to live in a high tower over the clouds'
fill_in 'spending_proposal_external_url', with: 'http://http://skyscraperpage.com/'
fill_in 'spending_proposal_captcha', with: correct_captcha_text
+ select 'All city', from: 'spending_proposal_geozone_id'
check 'spending_proposal_terms_of_service'
click_button 'Create'