diff --git a/app/controllers/spending_proposals_controller.rb b/app/controllers/spending_proposals_controller.rb
index e82ad3eef..a07783d3d 100644
--- a/app/controllers/spending_proposals_controller.rb
+++ b/app/controllers/spending_proposals_controller.rb
@@ -29,7 +29,7 @@ class SpendingProposalsController < ApplicationController
private
def spending_proposal_params
- params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :terms_of_service, :captcha, :captcha_key)
+ params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name, :terms_of_service, :captcha, :captcha_key)
end
def verify_valuator
diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb
index 4d097ad97..90d2b06f6 100644
--- a/app/models/spending_proposal.rb
+++ b/app/models/spending_proposal.rb
@@ -63,4 +63,5 @@ class SpendingProposal < ActiveRecord::Base
"undefined"
end
end
+
end
diff --git a/app/views/admin/spending_proposals/show.html.erb b/app/views/admin/spending_proposals/show.html.erb
index 2f4697a9c..4d3b57935 100644
--- a/app/views/admin/spending_proposals/show.html.erb
+++ b/app/views/admin/spending_proposals/show.html.erb
@@ -6,8 +6,15 @@
<%= text_with_links @spending_proposal.external_url %>
<% end %>
-<%= t("admin.spending_proposals.show.by") %>: <%= link_to @spending_proposal.author.name, admin_user_path(@spending_proposal.author) %>
-<%= t("admin.spending_proposals.show.geozone") %>: <%= geozone_name(@spending_proposal) %>
+<%= t("admin.spending_proposals.show.by") %>:
+ <%= link_to @spending_proposal.author.name, admin_user_path(@spending_proposal.author) %>
+
+<%= t("admin.spending_proposals.show.association_name") %>:
+ <%= @spending_proposal.association_name %>
+
+<%= t("admin.spending_proposals.show.geozone") %>:
+ <%= geozone_name(@spending_proposal) %>
+
<%= l @spending_proposal.created_at, format: :datetime %>
diff --git a/app/views/shared/_author_info.html.erb b/app/views/shared/_author_info.html.erb
index 7370ec10f..625888624 100644
--- a/app/views/shared/_author_info.html.erb
+++ b/app/views/shared/_author_info.html.erb
@@ -8,6 +8,13 @@
<%= link_to resource.author.name, user_path(resource.author) %>
+
+ <% if resource.respond_to?(:association_name) && resource.association_name.present? %>
+
+ <%= "(#{resource.association_name})" %>
+
+ <% end %>
+
<% if resource.author.official? %>
•
diff --git a/app/views/spending_proposals/_form.html.erb b/app/views/spending_proposals/_form.html.erb
index 4805b1bb4..b02618b55 100644
--- a/app/views/spending_proposals/_form.html.erb
+++ b/app/views/spending_proposals/_form.html.erb
@@ -22,6 +22,11 @@
<%= f.select :geozone_id, geozone_select_options, {include_blank: t("geozones.none"), label: false} %>
+
+ <%= f.label :association_name, t("spending_proposals.form.association_name_label") %>
+ <%= f.text_field :association_name, placeholder: t("spending_proposals.form.association_name"), label: false %>
+
+
<% if @spending_proposal.new_record? %>
<%= f.label :terms_of_service do %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index be52a41a8..1711c9221 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -148,6 +148,7 @@ en:
unresolved: Unresolved
title: Spending proposals for participatory budgeting
show:
+ association_name: Asociación
by: Sent by
geozone: Scope
dossier: Dossier
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index f2bd9f6a2..4ccdba39e 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -148,6 +148,7 @@ es:
unresolved: Sin resolver
title: Propuestas de gasto para presupuestos participativos
show:
+ association_name: Asociación
by: Enviada por
geozone: Ámbito
dossier: Informe
diff --git a/config/locales/en.yml b/config/locales/en.yml
index afb3b47ea..f89aa48a0 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -399,6 +399,8 @@ en:
youtube: YouTube
spending_proposals:
form:
+ association_name_label: 'If you propose in name of an assocation or collective add the name here'
+ association_name: 'Association name'
description: Description
external_url: Link to additional documentation
geozone: Scope of operation
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 048cde021..7b07bec45 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -400,6 +400,8 @@ es:
youtube: YouTube
spending_proposals:
form:
+ association_name_label: 'Si propones en nombre de una asociación o colectivo añade el nombre aquí'
+ association_name: 'Nombre de la asociación'
description: Descripción detallada
external_url: Enlace a documentación adicional
geozone: "Ámbito de actuación"
diff --git a/db/migrate/20160220181602_add_association_to_spending_proposals.rb b/db/migrate/20160220181602_add_association_to_spending_proposals.rb
new file mode 100644
index 000000000..17ded2bc3
--- /dev/null
+++ b/db/migrate/20160220181602_add_association_to_spending_proposals.rb
@@ -0,0 +1,5 @@
+class AddAssociationToSpendingProposals < ActiveRecord::Migration
+ def change
+ add_column :spending_proposals, :association_name, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index ba977e327..dd3633461 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20160219172824) do
+ActiveRecord::Schema.define(version: 20160220181602) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -294,14 +294,15 @@ ActiveRecord::Schema.define(version: 20160219172824) do
t.text "description"
t.integer "author_id"
t.string "external_url"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.integer "geozone_id"
t.string "resolution"
t.float "price"
t.boolean "legal"
t.boolean "feasible"
t.text "explanation"
+ t.string "association_name"
end
add_index "spending_proposals", ["author_id"], name: "index_spending_proposals_on_author_id", using: :btree
diff --git a/spec/features/admin/spending_proposals_spec.rb b/spec/features/admin/spending_proposals_spec.rb
index 9d8a33447..3b619dc3e 100644
--- a/spec/features/admin/spending_proposals_spec.rb
+++ b/spec/features/admin/spending_proposals_spec.rb
@@ -105,6 +105,7 @@ feature 'Admin spending proposals' do
scenario 'Show' do
spending_proposal = create(:spending_proposal,
geozone: create(:geozone),
+ association_name: 'People of the neighbourhood',
price: 1234.56,
legal: true,
feasible: false,
@@ -116,6 +117,7 @@ feature 'Admin spending proposals' do
expect(page).to have_content(spending_proposal.title)
expect(page).to have_content(spending_proposal.description)
expect(page).to have_content(spending_proposal.author.name)
+ expect(page).to have_content(spending_proposal.association_name)
expect(page).to have_content(spending_proposal.geozone.name)
expect(page).to have_content("1234.56")
expect(page).to have_content("Legal")
diff --git a/spec/features/spending_proposals_spec.rb b/spec/features/spending_proposals_spec.rb
index 6b76b02e0..9a4d56fd7 100644
--- a/spec/features/spending_proposals_spec.rb
+++ b/spec/features/spending_proposals_spec.rb
@@ -25,6 +25,7 @@ feature 'Spending proposals' do
fill_in 'spending_proposal_title', with: 'Build a skyscraper'
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_association_name', with: 'People of the neighbourhood'
fill_in 'spending_proposal_captcha', with: correct_captcha_text
select 'All city', from: 'spending_proposal_geozone_id'
check 'spending_proposal_terms_of_service'
@@ -63,4 +64,54 @@ feature 'Spending proposals' do
expect(page).to have_content error_message
end
+ scenario "Show (as admin)" do
+ user = create(:user)
+ admin = create(:administrator, user: user)
+ login_as(admin.user)
+
+ spending_proposal = create(:spending_proposal,
+ geozone: create(:geozone),
+ association_name: 'People of the neighbourhood')
+
+ visit spending_proposal_path(spending_proposal)
+
+ expect(page).to have_content(spending_proposal.title)
+ expect(page).to have_content(spending_proposal.description)
+ expect(page).to have_content(spending_proposal.author.name)
+ expect(page).to have_content(spending_proposal.association_name)
+ expect(page).to have_content(spending_proposal.geozone.name)
+ end
+
+ scenario "Show (as valuator)" do
+ user = create(:user)
+ admin = create(:valuator, user: user)
+ login_as(admin.user)
+
+ spending_proposal = create(:spending_proposal,
+ geozone: create(:geozone),
+ association_name: 'People of the neighbourhood')
+
+ visit spending_proposal_path(spending_proposal)
+
+ expect(page).to have_content(spending_proposal.title)
+ expect(page).to have_content(spending_proposal.description)
+ expect(page).to have_content(spending_proposal.author.name)
+ expect(page).to have_content(spending_proposal.association_name)
+ expect(page).to have_content(spending_proposal.geozone.name)
+ end
+
+ scenario "Show (as user)" do
+ user = create(:user)
+ login_as(user)
+
+ spending_proposal = create(:spending_proposal,
+ geozone: create(:geozone),
+ association_name: 'People of the neighbourhood')
+
+ visit spending_proposal_path(spending_proposal)
+
+ expect(page).to_not have_content(spending_proposal.title)
+ expect(page).to have_content("You do not have permission to access this page")
+ end
+
end