diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index 934db3a8d3b..d094aad1d63 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -172,4 +172,16 @@ def budget_subnav_items_for(budget) } end end + + def budget_subnav_items_for_only_results(budget) + { + results: t("budgets.results.link"), + }.select { |section, _| can?(:"read_#{section}", budget) }.map do |section, text| + { + text: text, + url: send("budget_#{section}_path", budget), + active: controller_name == section.to_s + } + end + end end diff --git a/app/views/budgets/_finished.html.erb b/app/views/budgets/_finished.html.erb index dd526bc0ffd..454bd88a7cf 100644 --- a/app/views/budgets/_finished.html.erb +++ b/app/views/budgets/_finished.html.erb @@ -1,14 +1,16 @@ <% budgets.each do |budget| %> -
-
-

<%= budget.name.gsub(/[A-Za-z ]*/,"") %> <%=t("budgets.landing.titleGen")%>

-

-

- <%= link_to t("budgets.index.see_results"), budget_results_path(budget), class: "a_list_budget" if can?(:read_results, budget) %> -
-
- <%= link_to t("budgets.index.milestones"), budget_executions_path(budget), class: "a_list_budget" if can?(:read_executions, budget) %> -
-

-
+ <%if budget.id != budgets.first.id %> +
+
+

<%= budget.name.gsub(/[A-Za-z ]*/,"") %> <%=t("budgets.landing.titleGen")%>

+

+

+ <%= link_to t("budgets.index.see_results"), budget_results_path(budget), class: "a_list_budget" if can?(:read_results, budget) %> +
+
+ <%= link_to t("budgets.index.milestones"), budget_executions_path(budget), class: "a_list_budget" if can?(:read_executions, budget) %> +
+

+
+ <% end %> <% end %> \ No newline at end of file diff --git a/app/views/budgets/_subnav.html.erb b/app/views/budgets/_subnav.html.erb index f5f96037720..82046ba795d 100644 --- a/app/views/budgets/_subnav.html.erb +++ b/app/views/budgets/_subnav.html.erb @@ -1,7 +1,7 @@
+ \ No newline at end of file diff --git a/app/views/budgets/results/_results_table.html.erb b/app/views/budgets/results/_results_table.html.erb index 120aa5abbb2..c55ea355488 100644 --- a/app/views/budgets/results/_results_table.html.erb +++ b/app/views/budgets/results/_results_table.html.erb @@ -10,18 +10,19 @@ <%= t("budgets.results.investment_title") %> - - <%= @budget.id < 5 ? t("budgets.results.ballot_lines_count") : t("budgets.results.voters") %> - - <%if @budget.id >= 5%> + <%if @budget.id < 5%> - <%= t("budgets.results.ballot_lines_count_positive") %> + <%= t("budgets.results.ballot_lines_count")%> + <%else%> - <%= t("budgets.results.ballot_lines_count_negative") %> + <%= t("budgets.results.ballot_lines_count_total") %> - <%= t("budgets.results.ballot_lines_count_total") %> + <%= t("budgets.results.ballot_lines_count_positive") %> + + + <%= t("budgets.results.ballot_lines_count_negative") %> <%end%> @@ -38,7 +39,7 @@ <% amount_available = heading_price %> - <% investments.each do |investment| %> + <% investments.order(result_balloting_votes: :desc).each do |investment| %> " style="<%= investment.winner? ? "" : "display: none" %>"> @@ -58,19 +59,20 @@ <% end %> <%= link_to investment.title, budget_investment_path(@budget, investment) %> - - <%= investment.ballot_lines_count %> - - <%if investment.budget.id >= 5%> + <%if investment.budget.id < 5%> - <%= investment.ballot_lines_up_votes %> + <%= investment.ballot_lines_count %> + <%else%> - <%= investment.ballot_lines_down_votes %> + <%= investment.ballot_lines_total_votes %> - <%= investment.ballot_lines_total_votes %> + <%= investment.ballot_lines_up_votes %> + + <%= investment.ballot_lines_down_votes %> + <%end%> <%= @budget.formatted_amount(investment.price.to_i !=0 ? investment.price : investment.total_amount) %> @@ -78,8 +80,12 @@ <% if results_type == :compatible %> - <%= @budget.formatted_amount(amount_available - investment.price.to_i != 0 ? investment.price.to_i : investment.total_amount.to_i) %> - <% amount_available -= investment.price.to_i != 0 ? investment.price.to_i : investment.total_amount.to_i if investment.winner? %> + <% if investment.winner?%> + <%= @budget.formatted_amount(amount_available.to_i - (investment.price.to_i != 0 ? investment.price.to_i : investment.total_amount.to_i))%> + <% amount_available -= investment.price.to_i != 0 ? investment.price.to_i : investment.total_amount.to_i %> + <%else%> + <%= @budget.formatted_amount(amount_available.to_i) %> + <%end%> <% end %> diff --git a/db/migrate/20220713113602_add_result_balloting_votes_to_budget_investments.rb b/db/migrate/20220713113602_add_result_balloting_votes_to_budget_investments.rb new file mode 100644 index 00000000000..5fb63443a53 --- /dev/null +++ b/db/migrate/20220713113602_add_result_balloting_votes_to_budget_investments.rb @@ -0,0 +1,5 @@ +class AddResultBallotingVotesToBudgetInvestments < ActiveRecord::Migration[5.0] + def change + add_column :budget_investments, :result_balloting_votes, :float + end +end diff --git a/lib/tasks/import_data.rake b/lib/tasks/import_data.rake index 2f7dbb5e268..377f5b67cd0 100644 --- a/lib/tasks/import_data.rake +++ b/lib/tasks/import_data.rake @@ -836,7 +836,13 @@ namespace :import_data do NewsletterStatus.find_or_create_by( name: "Envío terminado", code: "finish") end - + desc "Añadir resultados totales a budget_investments" + task add_result_balloting: :environment do + Budget.find(5).investments.find_each do |inv| + inv.result_balloting_votes = inv.ballot_lines_total_votes + inv.save(validate: false) + end + end end