Merge pull request #911 from consul/association-name
Adds an association name to spending proposals
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -63,4 +63,5 @@ class SpendingProposal < ActiveRecord::Base
|
||||
"undefined"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -6,8 +6,15 @@
|
||||
<p><%= text_with_links @spending_proposal.external_url %></p>
|
||||
<% end %>
|
||||
|
||||
<p><%= t("admin.spending_proposals.show.by") %>: <%= link_to @spending_proposal.author.name, admin_user_path(@spending_proposal.author) %></p>
|
||||
<p><%= t("admin.spending_proposals.show.geozone") %>: <%= geozone_name(@spending_proposal) %></p>
|
||||
<p><%= t("admin.spending_proposals.show.by") %>:
|
||||
<%= link_to @spending_proposal.author.name, admin_user_path(@spending_proposal.author) %>
|
||||
</p>
|
||||
<p><%= t("admin.spending_proposals.show.association_name") %>:
|
||||
<%= @spending_proposal.association_name %>
|
||||
</p>
|
||||
<p><%= t("admin.spending_proposals.show.geozone") %>:
|
||||
<%= geozone_name(@spending_proposal) %>
|
||||
</p>
|
||||
<p><%= l @spending_proposal.created_at, format: :datetime %></p>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
<span class="author">
|
||||
<%= link_to resource.author.name, user_path(resource.author) %>
|
||||
</span>
|
||||
|
||||
<% if resource.respond_to?(:association_name) && resource.association_name.present? %>
|
||||
<span>
|
||||
<%= "(#{resource.association_name})" %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<% if resource.author.official? %>
|
||||
•
|
||||
<span class="label round level-<%= resource.author.official_level %>">
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
<%= f.select :geozone_id, geozone_select_options, {include_blank: t("geozones.none"), label: false} %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= 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 %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<% if @spending_proposal.new_record? %>
|
||||
<%= f.label :terms_of_service do %>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddAssociationToSpendingProposals < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :spending_proposals, :association_name, :string
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user