adds summary of spending proposals by valuator
This commit is contained in:
@@ -25,6 +25,10 @@ class Admin::ValuatorsController < Admin::BaseController
|
||||
redirect_to admin_valuators_path
|
||||
end
|
||||
|
||||
def summary
|
||||
@valuators = Valuator.all
|
||||
end
|
||||
|
||||
private
|
||||
def create_params
|
||||
params[:valuator][:description] = nil if params[:valuator][:description].blank?
|
||||
|
||||
@@ -36,7 +36,7 @@ module Abilities
|
||||
can :comment_as_administrator, [Debate, Comment, Proposal]
|
||||
|
||||
can [:search, :create, :index, :destroy], ::Moderator
|
||||
can [:search, :create, :index], ::Valuator
|
||||
can [:search, :create, :index, :summary], ::Valuator
|
||||
|
||||
can :manage, Annotation
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
summary_admin_spending_proposals_path,
|
||||
class: "button float-right" %>
|
||||
|
||||
<%= link_to t("admin.spending_proposals.index.valuator_summary_link"),
|
||||
summary_admin_valuators_path,
|
||||
class: "button float-right" %>
|
||||
|
||||
<h2 class="inline-block"><%= t("admin.spending_proposals.index.title") %></h2>
|
||||
|
||||
<div class="row margin">
|
||||
|
||||
42
app/views/admin/valuators/summary.html.erb
Normal file
42
app/views/admin/valuators/summary.html.erb
Normal file
@@ -0,0 +1,42 @@
|
||||
<%= link_to admin_spending_proposals_path, class: "back" do %>
|
||||
<span class="icon-angle-left"></span>
|
||||
<%= t("shared.back") %>
|
||||
<% end %>
|
||||
|
||||
<h2><%= t("admin.valuators.summary.title") %></h2>
|
||||
|
||||
<table id="spending_proposals" class="investment-projects-summary">
|
||||
<th><%= t("admin.valuators.summary.valuator_name") %></th>
|
||||
<th><%= t("admin.valuators.summary.finished_and_feasible_count") %></th>
|
||||
<th><%= t("admin.valuators.summary.finished_and_unfeasible_count") %></th>
|
||||
<th><%= t("admin.valuators.summary.finished_count") %></th>
|
||||
<th><%= t("admin.valuators.summary.in_evaluation_count") %></th>
|
||||
<th><%= t("admin.valuators.summary.total_count") %></th>
|
||||
<th><%= t("admin.valuators.summary.cost") %></th>
|
||||
|
||||
<% @valuators.each do |valuator| %>
|
||||
<tr id="<%= dom_id(valuator) %>">
|
||||
<td class="name">
|
||||
<%= valuator.description_or_email %>
|
||||
</td>
|
||||
<td class="finished-and-feasible-count">
|
||||
<%= valuator.spending_proposals.finished_and_feasible.count %>
|
||||
</td>
|
||||
<td class="finished-and-unfeasible-count">
|
||||
<%= valuator.spending_proposals.finished_and_unfeasible.count %>
|
||||
</td>
|
||||
<td class="finished-count">
|
||||
<%= valuator.spending_proposals.valuation_finished.count %>
|
||||
</td>
|
||||
<td class="in-evaluation-count">
|
||||
<%= valuator.spending_proposals.valuating.count %>
|
||||
</td>
|
||||
<td class="total-count">
|
||||
<%= valuator.spending_proposals.count %>
|
||||
</td>
|
||||
<td class="total-price text-center">
|
||||
<%= number_to_currency(valuator.spending_proposals.sum(:price)) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
@@ -83,6 +83,15 @@ en:
|
||||
email_placeholder: Search user by email
|
||||
search: Search
|
||||
user_not_found: User not found
|
||||
summary:
|
||||
title: Valuator summary for investment projects
|
||||
valuator_name: Valuator
|
||||
finished_and_feasible_count: Finished and feasible
|
||||
finished_and_unfeasible_count: Finished and unfeasible
|
||||
finished_count: Finished
|
||||
in_evaluation_count: In evaluation
|
||||
total_count: Total
|
||||
cost: Cost
|
||||
officials:
|
||||
edit:
|
||||
back: Back
|
||||
@@ -170,7 +179,8 @@ en:
|
||||
assigned_admin: Assigned administrator
|
||||
no_admin_assigned: No admin assigned
|
||||
no_valuators_assigned: No valuators assigned
|
||||
summary_link: "Summary"
|
||||
summary_link: "Investment project summary"
|
||||
valuator_summary_link: "Valuator summary"
|
||||
feasibility:
|
||||
feasible: "Feasible (%{price})"
|
||||
not_feasible: "Not feasible"
|
||||
|
||||
@@ -83,6 +83,15 @@ es:
|
||||
email_placeholder: Buscar usuario por email
|
||||
search: Buscar
|
||||
user_not_found: Usuario no encontrado
|
||||
summary:
|
||||
title: Resumen de evaluación de propuestas de inversión
|
||||
valuator_name: Evaluador
|
||||
finished_and_feasible_count: Finalizadas viables
|
||||
finished_and_unfeasible_count: Finalizadas inviables
|
||||
finished_count: Finalizadas
|
||||
in_evaluation_count: En evaluación
|
||||
total_count: Total
|
||||
cost: Coste total
|
||||
officials:
|
||||
edit:
|
||||
back: Volver
|
||||
@@ -170,7 +179,8 @@ es:
|
||||
assigned_admin: Administrador asignado
|
||||
no_admin_assigned: Sin admin asignado
|
||||
no_valuators_assigned: Sin evaluador
|
||||
summary_link: "Resumen"
|
||||
summary_link: "Resumen de propuestas"
|
||||
valuator_summary_link: "Resumen de evaluadores"
|
||||
feasibility:
|
||||
feasible: "Viable (%{price})"
|
||||
not_feasible: "Inviable"
|
||||
@@ -203,7 +213,7 @@ es:
|
||||
title_proposals_with_supports: Resumen para propuestas que han superado la fase de apoyos
|
||||
geozone_name: Ámbito de ciudad
|
||||
finished_and_feasible_count: Finalizadas viables
|
||||
finished_and_unfeasible_count: Finished inviables
|
||||
finished_and_unfeasible_count: Finalizadas inviables
|
||||
finished_count: Finalizadas
|
||||
in_evaluation_count: En evaluación
|
||||
total_count: Total
|
||||
|
||||
@@ -162,6 +162,7 @@ Rails.application.routes.draw do
|
||||
|
||||
resources :valuators, only: [:index, :create] do
|
||||
get :search, on: :collection
|
||||
get :summary, on: :collection
|
||||
end
|
||||
|
||||
resources :verifications, controller: :verifications, only: :index do
|
||||
|
||||
@@ -458,7 +458,7 @@ feature 'Admin spending proposals' do
|
||||
|
||||
visit admin_spending_proposals_path
|
||||
|
||||
click_link "Summary"
|
||||
click_link "Investment project summary"
|
||||
|
||||
expect(page).to have_content "Summary for investment projects"
|
||||
|
||||
@@ -493,7 +493,7 @@ feature 'Admin spending proposals' do
|
||||
|
||||
visit admin_spending_proposals_path
|
||||
|
||||
click_link "Summary"
|
||||
click_link "Investment project summary"
|
||||
|
||||
expect(page).to have_content "Summary for investment projects"
|
||||
|
||||
@@ -524,7 +524,7 @@ feature 'Admin spending proposals' do
|
||||
|
||||
visit admin_spending_proposals_path
|
||||
|
||||
click_link "Summary"
|
||||
click_link "Investment project summary"
|
||||
|
||||
expect(page).to have_content "Summary for investment projects"
|
||||
|
||||
@@ -554,7 +554,7 @@ feature 'Admin spending proposals' do
|
||||
|
||||
visit admin_spending_proposals_path
|
||||
|
||||
click_link "Summary"
|
||||
click_link "Investment project summary"
|
||||
|
||||
expect(page).to have_content "Summary for investment projects"
|
||||
|
||||
@@ -590,7 +590,7 @@ feature 'Admin spending proposals' do
|
||||
|
||||
visit admin_spending_proposals_path
|
||||
|
||||
click_link "Summary"
|
||||
click_link "Investment project summary"
|
||||
|
||||
expect(page).to have_content "Summary for investment projects"
|
||||
|
||||
@@ -627,7 +627,7 @@ feature 'Admin spending proposals' do
|
||||
|
||||
visit admin_spending_proposals_path
|
||||
|
||||
click_link "Summary"
|
||||
click_link "Investment project summary"
|
||||
|
||||
expect(page).to have_content "Summary for investment projects"
|
||||
|
||||
|
||||
@@ -388,4 +388,70 @@ feature 'Valuation spending proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
context "Summary" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
scenario "Summary table" do
|
||||
scarlett = create(:valuator)
|
||||
john = create(:valuator)
|
||||
|
||||
finished_and_feasible1 = create(:spending_proposal, valuation_finished: true, feasible: true, price: '3000000')
|
||||
finished_and_feasible2 = create(:spending_proposal, valuation_finished: true, feasible: true, price: '7000000')
|
||||
|
||||
finished_and_unfeasible1 = create(:spending_proposal, valuation_finished: true, feasible: false)
|
||||
finished_and_unfeasible2 = create(:spending_proposal, valuation_finished: true, feasible: false)
|
||||
|
||||
in_evaluation1 = create(:spending_proposal, feasible: true, valuation_finished: false)
|
||||
in_evaluation2 = create(:spending_proposal, feasible: true, valuation_finished: false)
|
||||
|
||||
|
||||
finished_and_feasible1.valuators << scarlett
|
||||
finished_and_feasible2.valuators << scarlett
|
||||
|
||||
finished_and_unfeasible1.valuators << john
|
||||
finished_and_unfeasible2.valuators << john
|
||||
|
||||
in_evaluation1.valuators << scarlett
|
||||
in_evaluation2.valuators << john
|
||||
|
||||
visit admin_spending_proposals_path
|
||||
|
||||
click_link "Valuator Summary"
|
||||
|
||||
expect(page).to have_content "Valuator summary for investment projects"
|
||||
|
||||
within("#valuator_#{scarlett.id}") do
|
||||
expect(page).to have_css(".finished-and-feasible-count", text: '2')
|
||||
expect(page).to have_css(".finished-and-unfeasible-count", text: '0')
|
||||
expect(page).to have_css(".finished-count", text: '2')
|
||||
expect(page).to have_css(".in-evaluation-count", text: '1')
|
||||
expect(page).to have_css(".total-count", text: '3')
|
||||
expect(page).to have_css(".total-price", text: "$10,000,000.00")
|
||||
end
|
||||
|
||||
within("#valuator_#{john.id}") do
|
||||
expect(page).to have_css(".finished-and-feasible-count", text: '0')
|
||||
expect(page).to have_css(".finished-and-unfeasible-count", text: '2')
|
||||
expect(page).to have_css(".finished-count", text: '2')
|
||||
expect(page).to have_css(".in-evaluation-count", text: '1')
|
||||
expect(page).to have_css(".total-count", text: '3')
|
||||
expect(page).to have_css(".total-price", text: '$0.00')
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Back link" do
|
||||
visit admin_spending_proposals_path
|
||||
|
||||
click_link "Valuator Summary"
|
||||
expect(page).to have_content "Valuator summary for investment projects"
|
||||
|
||||
click_link "Back"
|
||||
expect(page).to have_content "Investment projects for participatory budgeting"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user