Add Valuator Groups list to investment csv & table

We've added the list of valuator groups assigned to each investment at
 both admin investment list and investment csv exported file
This commit is contained in:
Bertocq
2018-04-11 21:12:46 +02:00
parent b364fc475e
commit 1dc8d29f2d
5 changed files with 28 additions and 11 deletions

View File

@@ -334,6 +334,7 @@ class Budget
I18n.t("admin.budget_investments.index.table_supports"), I18n.t("admin.budget_investments.index.table_supports"),
I18n.t("admin.budget_investments.index.table_admin"), I18n.t("admin.budget_investments.index.table_admin"),
I18n.t("admin.budget_investments.index.table_valuator"), I18n.t("admin.budget_investments.index.table_valuator"),
I18n.t("admin.budget_investments.index.table_valuation_group"),
I18n.t("admin.budget_investments.index.table_geozone"), I18n.t("admin.budget_investments.index.table_geozone"),
I18n.t("admin.budget_investments.index.table_feasibility"), I18n.t("admin.budget_investments.index.table_feasibility"),
I18n.t("admin.budget_investments.index.table_valuation_finished"), I18n.t("admin.budget_investments.index.table_valuation_finished"),
@@ -349,6 +350,8 @@ class Budget
else else
I18n.t("admin.budget_investments.index.no_admin_assigned") I18n.t("admin.budget_investments.index.no_admin_assigned")
end end
assigned_valuators = investment.assigned_valuators || '-'
assigned_valuation_groups = investment.assigned_valuation_groups || '-'
vals = if investment.valuators.empty? vals = if investment.valuators.empty?
I18n.t("admin.budget_investments.index.no_valuators_assigned") I18n.t("admin.budget_investments.index.no_valuators_assigned")
else else
@@ -361,8 +364,8 @@ class Budget
valuation_finished = investment.valuation_finished? ? valuation_finished = investment.valuation_finished? ?
I18n.t('shared.yes') : I18n.t('shared.yes') :
I18n.t('shared.no') I18n.t('shared.no')
csv << [id, title, total_votes, admin, vals, heading_name, price, csv << [id, title, total_votes, admin, assigned_valuators, assigned_valuation_groups,
valuation_finished] heading_name, price, valuation_finished]
end end
end end
csv_string csv_string

View File

@@ -24,6 +24,7 @@
<th><%= t("admin.budget_investments.index.table_supports") %></th> <th><%= t("admin.budget_investments.index.table_supports") %></th>
<th><%= t("admin.budget_investments.index.table_admin") %></th> <th><%= t("admin.budget_investments.index.table_admin") %></th>
<th><%= t("admin.budget_investments.index.table_valuator") %></th> <th><%= t("admin.budget_investments.index.table_valuator") %></th>
<th><%= t("admin.budget_investments.index.table_valuation_group") %></th>
<th><%= t("admin.budget_investments.index.table_geozone") %></th> <th><%= t("admin.budget_investments.index.table_geozone") %></th>
<th><%= t("admin.budget_investments.index.table_feasibility") %></th> <th><%= t("admin.budget_investments.index.table_feasibility") %></th>
<th class="text-center"><%= t("admin.budget_investments.index.table_valuation_finished") %></th> <th class="text-center"><%= t("admin.budget_investments.index.table_valuation_finished") %></th>
@@ -60,11 +61,12 @@
<% end %> <% end %>
</td> </td>
<td class="small"> <td class="small">
<% if investment.valuators.size == 0 && investment.valuator_groups.size == 0 %> <% no_valuators_assigned = t("admin.budget_investments.index.no_valuators_assigned") %>
<%= t("admin.budget_investments.index.no_valuators_assigned") %> <%= investment.assigned_valuators || no_valuators_assigned %>
<% else %> </td>
<%= investment.assigned_valuators %> <td class="small">
<% end %> <% no_valuation_groups = t("admin.budget_investments.index.no_valuation_groups") %>
<%= investment.assigned_valuation_groups || no_valuation_groups %>
</td> </td>
<td class="small"> <td class="small">
<%= investment.heading.name %> <%= investment.heading.name %>

View File

@@ -171,6 +171,7 @@ en:
assigned_admin: Assigned administrator assigned_admin: Assigned administrator
no_admin_assigned: No admin assigned no_admin_assigned: No admin assigned
no_valuators_assigned: No valuators assigned no_valuators_assigned: No valuators assigned
no_valuation_groups: No valuation groups assigned
feasibility: feasibility:
feasible: "Feasible (%{price})" feasible: "Feasible (%{price})"
unfeasible: "Unfeasible" unfeasible: "Unfeasible"
@@ -182,6 +183,7 @@ en:
table_supports: "Supports" table_supports: "Supports"
table_admin: "Administrator" table_admin: "Administrator"
table_valuator: "Valuator" table_valuator: "Valuator"
table_valuation_group: "Valuation Group"
table_geozone: "Scope of operation" table_geozone: "Scope of operation"
table_feasibility: "Feasibility" table_feasibility: "Feasibility"
table_valuation_finished: "Val. Fin." table_valuation_finished: "Val. Fin."

View File

@@ -171,6 +171,7 @@ es:
assigned_admin: Administrador asignado assigned_admin: Administrador asignado
no_admin_assigned: Sin admin asignado no_admin_assigned: Sin admin asignado
no_valuators_assigned: Sin evaluador no_valuators_assigned: Sin evaluador
no_valuation_groups: Sin grupos evaluadores
feasibility: feasibility:
feasible: "Viable (%{price})" feasible: "Viable (%{price})"
unfeasible: "Inviable" unfeasible: "Inviable"
@@ -182,6 +183,7 @@ es:
table_supports: "Apoyos" table_supports: "Apoyos"
table_admin: "Administrador" table_admin: "Administrador"
table_valuator: "Evaluador" table_valuator: "Evaluador"
table_valuation_group: "Grupos evaluadores"
table_geozone: "Ámbito de actuación" table_geozone: "Ámbito de actuación"
table_feasibility: "Viabilidad" table_feasibility: "Viabilidad"
table_valuation_finished: "Ev. Fin." table_valuation_finished: "Ev. Fin."

View File

@@ -64,22 +64,27 @@ feature 'Admin budget investments' do
admin = create(:administrator, user: create(:user, username: 'Gema')) admin = create(:administrator, user: create(:user, username: 'Gema'))
budget_investment1.valuators << valuator1 budget_investment1.valuators << valuator1
budget_investment2.valuator_ids = [valuator1.id, valuator2.id] budget_investment2.valuators << valuator1
budget_investment3.update(administrator_id: admin.id) budget_investment2.valuators << valuator2
visit admin_budget_budget_investments_path(budget_id: budget.id) visit admin_budget_budget_investments_path(budget_id: budget.id)
within("#budget_investment_#{budget_investment1.id}") do within("#budget_investment_#{budget_investment1.id}") do
expect(page).to have_content("No admin assigned") expect(page).to have_content("No admin assigned")
expect(page).to have_content("Valuator Olga") expect(page).to have_content("Valuator Olga")
expect(page).to have_content("No valuation groups assigned")
end end
within("#budget_investment_#{budget_investment2.id}") do within("#budget_investment_#{budget_investment2.id}") do
expect(page).to have_content("No admin assigned") expect(page).to have_content("No admin assigned")
expect(page).to have_content("Valuator Olga") expect(page).to have_content("Valuator Olga")
expect(page).to have_content("Valuator Miriam") expect(page).to have_content("Valuator Miriam")
expect(page).to have_content("No valuation groups assigned")
end end
budget_investment3.update(administrator_id: admin.id)
visit admin_budget_budget_investments_path(budget_id: budget.id)
within("#budget_investment_#{budget_investment3.id}") do within("#budget_investment_#{budget_investment3.id}") do
expect(page).to have_content("Gema") expect(page).to have_content("Gema")
expect(page).to have_content("No valuators assigned") expect(page).to have_content("No valuators assigned")
@@ -109,7 +114,7 @@ feature 'Admin budget investments' do
end end
within("#budget_investment_#{budget_investment3.id}") do within("#budget_investment_#{budget_investment3.id}") do
expect(page).to have_content("No valuators assigned") expect(page).to have_content("No valuation groups assigned")
end end
end end
@@ -953,7 +958,9 @@ feature 'Admin budget investments' do
price: 100) price: 100)
valuator = create(:valuator, user: create(:user, username: 'Rachel', valuator = create(:valuator, user: create(:user, username: 'Rachel',
email: 'rachel@val.org')) email: 'rachel@val.org'))
investment.valuators.push(valuator) group = create(:valuator_group, name: "Test name")
investment.valuator_groups << group
admin = create(:administrator, user: create(:user, username: 'Gema')) admin = create(:administrator, user: create(:user, username: 'Gema'))
investment.update(administrator_id: admin.id) investment.update(administrator_id: admin.id)
@@ -978,6 +985,7 @@ feature 'Admin budget investments' do
expect(page).to have_content investment.administrator.name expect(page).to have_content investment.administrator.name
expect(page).to have_content valuators expect(page).to have_content valuators
expect(page).to have_content group.name
expect(page).to have_content price expect(page).to have_content price
expect(page).to have_content I18n.t('shared.no') expect(page).to have_content I18n.t('shared.no')
end end