@@ -21,10 +21,8 @@ class Admin::SpendingProposalsController < Admin::BaseController
|
||||
|
||||
def update
|
||||
if @spending_proposal.update(spending_proposal_params)
|
||||
path = admin_spending_proposal_path( @spending_proposal,
|
||||
{ anchor: 'classification' }.merge(SpendingProposal.filter_params(params)))
|
||||
|
||||
redirect_to path, notice: t("flash.actions.update.spending_proposal")
|
||||
redirect_to admin_spending_proposal_path(@spending_proposal, SpendingProposal.filter_params(params)),
|
||||
notice: t("flash.actions.update.spending_proposal")
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
@@ -33,7 +31,7 @@ class Admin::SpendingProposalsController < Admin::BaseController
|
||||
private
|
||||
|
||||
def spending_proposal_params
|
||||
params.require(:spending_proposal).permit(:administrator_id, :tag_list, valuator_ids: [])
|
||||
params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name, :administrator_id, :tag_list, valuator_ids: [])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,43 +2,71 @@
|
||||
<span class="icon-angle-left"></span> <%= t("admin.spending_proposals.show.back") %>
|
||||
<% end %>
|
||||
|
||||
<%= render 'written_by_author' %>
|
||||
|
||||
<h2 id="form"><%= t("admin.spending_proposals.edit.classification") %></h2>
|
||||
|
||||
<%= form_for @spending_proposal,
|
||||
url: admin_spending_proposal_path(@spending_proposal) do |f| %>
|
||||
|
||||
<% SpendingProposal.filter_params(params).each do |filter_name, filter_value| %>
|
||||
<%= hidden_field_tag filter_name, filter_value %>
|
||||
<%= hidden_field_tag filter_name, filter_value %>
|
||||
<% end %>
|
||||
|
||||
<%= f.select(:administrator_id,
|
||||
@admins.collect{ |a| [a.name_and_email, a.id ] },
|
||||
{ include_blank: t("admin.spending_proposals.edit.undefined") },
|
||||
class: "small-12 medium-6") %>
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :title, maxlength: SpendingProposal.title_max_length %>
|
||||
</div>
|
||||
|
||||
<%= f.label :tag_list, t("admin.spending_proposals.edit.tags") %>
|
||||
<div class="tags">
|
||||
<% @tags.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
||||
<% end %>
|
||||
<div class="ckeditor small-12 column">
|
||||
<%= f.cktext_area :description, maxlength: SpendingProposal.description_max_length, ckeditor: { language: I18n.locale } %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :external_url %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.select :geozone_id, geozone_select_options, include_blank: t("geozones.none") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :association_name, placeholder: t("spending_proposals.form.association_name") %>
|
||||
</div>
|
||||
</div>
|
||||
<%= f.text_field :tag_list, value: @spending_proposal.tag_list.to_s,
|
||||
label: false,
|
||||
placeholder: t("admin.spending_proposals.edit.tags_placeholder"),
|
||||
class: 'js-tag-list' %>
|
||||
|
||||
<%= f.label :valuator_ids, t("admin.spending_proposals.edit.assigned_valuators") %>
|
||||
<h2 id="classification"><%= t("admin.spending_proposals.edit.classification") %></h2>
|
||||
|
||||
<%= f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %>
|
||||
<%= b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.select(:administrator_id,
|
||||
@admins.collect{ |a| [a.name_and_email, a.id ] },
|
||||
{ include_blank: t("admin.spending_proposals.edit.undefined") }) %>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :tag_list, t("admin.spending_proposals.edit.tags") %>
|
||||
<div class="tags">
|
||||
<% @tags.each do |tag| %>
|
||||
<a class="js-add-tag-link"><%= tag.name %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= f.text_field :tag_list, value: @spending_proposal.tag_list.to_s,
|
||||
label: false,
|
||||
placeholder: t("admin.spending_proposals.edit.tags_placeholder"),
|
||||
class: 'js-tag-list' %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :valuator_ids, t("admin.spending_proposals.edit.assigned_valuators") %>
|
||||
|
||||
<%= f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %>
|
||||
<%= b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="clear">
|
||||
<%= f.submit(class: "button", value: t("admin.spending_proposals.edit.submit_button")) %>
|
||||
</p>
|
||||
|
||||
<% end %>
|
||||
|
||||
<hr>
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
<%= render 'written_by_author' %>
|
||||
|
||||
<h2 id="classification"><%= t("admin.spending_proposals.show.classification") %></h2>
|
||||
<%= link_to t("admin.spending_proposals.show.edit"),
|
||||
edit_admin_spending_proposal_path(@spending_proposal,
|
||||
SpendingProposal.filter_params(params)) %>
|
||||
|
||||
<p>
|
||||
<%= link_to t("admin.spending_proposals.show.edit_classification"),
|
||||
edit_admin_spending_proposal_path(@spending_proposal,
|
||||
{anchor: 'form'}.merge(SpendingProposal.filter_params(params))) %>
|
||||
</p>
|
||||
<hr>
|
||||
|
||||
<h2 id="classification"><%= t("admin.spending_proposals.show.classification") %></h2>
|
||||
|
||||
<p><strong><%= t("admin.spending_proposals.show.assigned_admin") %>:</strong>
|
||||
<%= @spending_proposal.administrator.try(:name_and_email) || t("admin.spending_proposals.show.undefined") %>
|
||||
@@ -31,12 +31,19 @@
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= link_to t("admin.spending_proposals.show.edit_classification"),
|
||||
edit_admin_spending_proposal_path(@spending_proposal,
|
||||
{anchor: 'classification'}.merge(SpendingProposal.filter_params(params))) %>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2><%= t("admin.spending_proposals.show.dossier") %></h2>
|
||||
|
||||
<%= render 'valuation/spending_proposals/written_by_valuators' %>
|
||||
|
||||
<p>
|
||||
<%= link_to t("admin.spending_proposals.show.edit_dossier"), edit_valuation_spending_proposal_path(@spending_proposal) %>
|
||||
</p>
|
||||
|
||||
<%= render 'valuation/spending_proposals/written_by_valuators' %>
|
||||
|
||||
@@ -68,7 +68,12 @@ en:
|
||||
name: "Name of organisation"
|
||||
responsible_name: "Person responsible for the group"
|
||||
spending_proposal:
|
||||
administrator_id: "Administrator"
|
||||
administrator_id: "Administrador"
|
||||
association_name: "Association name"
|
||||
description: "Description"
|
||||
external_url: "Link to additional documentation"
|
||||
geozone_id: "Scope of operation"
|
||||
title: "Title"
|
||||
errors:
|
||||
models:
|
||||
debate:
|
||||
|
||||
@@ -69,6 +69,11 @@ es:
|
||||
responsible_name: "Persona responsable del colectivo"
|
||||
spending_proposal:
|
||||
administrator_id: "Administrador"
|
||||
association_name: "Nombre de la asociación"
|
||||
description: "Descripción"
|
||||
external_url: "Enlace a documentación adicional"
|
||||
geozone_id: "Ámbito de actuación"
|
||||
title: "Título"
|
||||
errors:
|
||||
models:
|
||||
debate:
|
||||
|
||||
@@ -173,6 +173,7 @@ en:
|
||||
back: Back
|
||||
classification: Clasification
|
||||
heading: "Investment project %{id}"
|
||||
edit: Edit
|
||||
edit_classification: Edit classification
|
||||
association_name: Association
|
||||
by: By
|
||||
@@ -237,4 +238,4 @@ en:
|
||||
index:
|
||||
phone_not_given: Phone not given
|
||||
sms_code_not_confirmed: Has not confirmed the sms code
|
||||
title: Incomplete verifications
|
||||
title: Incomplete verifications
|
||||
|
||||
@@ -173,6 +173,7 @@ es:
|
||||
back: Volver
|
||||
classification: Clasificación
|
||||
heading: Propuesta de inversión %{id}
|
||||
edit: Editar
|
||||
edit_classification: Editar clasificación
|
||||
association_name: Asociación
|
||||
by: Autor
|
||||
|
||||
@@ -330,6 +330,24 @@ feature 'Admin spending proposals' do
|
||||
|
||||
context "Edit" do
|
||||
|
||||
scenario "Change title, description or geozone" do
|
||||
spending_proposal = create(:spending_proposal)
|
||||
create(:geozone, name: "Barbate")
|
||||
|
||||
visit admin_spending_proposal_path(spending_proposal)
|
||||
click_link 'Edit'
|
||||
|
||||
fill_in 'spending_proposal_title', with: 'Potatoes'
|
||||
fill_in 'spending_proposal_description', with: 'Carrots'
|
||||
select 'Barbate', from: 'spending_proposal[geozone_id]'
|
||||
|
||||
click_button 'Update'
|
||||
|
||||
expect(page).to have_content 'Potatoes'
|
||||
expect(page).to have_content 'Carrots'
|
||||
expect(page).to have_content 'Barbate'
|
||||
end
|
||||
|
||||
scenario "Add administrator" do
|
||||
spending_proposal = create(:spending_proposal)
|
||||
administrator = create(:administrator, user: create(:user, username: 'Marta', email: 'marta@admins.org'))
|
||||
|
||||
Reference in New Issue
Block a user