Skip to content

Commit

Permalink
[DEMAD-441] Ocultar navegación a estadísticas
Browse files Browse the repository at this point in the history
  • Loading branch information
vanessasotob committed Jul 13, 2022
1 parent 946167d commit b7e5ea4
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 31 deletions.
12 changes: 12 additions & 0 deletions app/helpers/budgets_helper.rb
Expand Up @@ -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
26 changes: 14 additions & 12 deletions app/views/budgets/_finished.html.erb
@@ -1,14 +1,16 @@
<% budgets.each do |budget| %>
<div class="small-12 column" style="margin-bottom: 1rem">
<hr>
<p><b><%= budget.name.gsub(/[A-Za-z ]*/,"") %></b> <%=t("budgets.landing.titleGen")%></p>
<p>
<div class="small-12 medium-6 column" style="padding: 0">
<%= link_to t("budgets.index.see_results"), budget_results_path(budget), class: "a_list_budget" if can?(:read_results, budget) %>
</div>
<div class="small-12 medium-6 column" style="padding: 0">
<%= link_to t("budgets.index.milestones"), budget_executions_path(budget), class: "a_list_budget" if can?(:read_executions, budget) %>
</div>
</p>
</div>
<%if budget.id != budgets.first.id %>
<div class="small-12 column" style="margin-bottom: 1rem">
<hr>
<p><b><%= budget.name.gsub(/[A-Za-z ]*/,"") %></b> <%=t("budgets.landing.titleGen")%></p>
<p>
<div class="small-12 medium-6 column" style="padding: 0">
<%= link_to t("budgets.index.see_results"), budget_results_path(budget), class: "a_list_budget" if can?(:read_results, budget) %>
</div>
<div class="small-12 medium-6 column" style="padding: 0">
<%= link_to t("budgets.index.milestones"), budget_executions_path(budget), class: "a_list_budget" if can?(:read_executions, budget) %>
</div>
</p>
</div>
<% end %>
<% end %>
3 changes: 2 additions & 1 deletion app/views/budgets/_subnav.html.erb
@@ -1,7 +1,7 @@
<div class="row margin-top">
<div class="small-12 column">
<ul class="tabs">
<% budget_subnav_items_for(budget).each do |item| %>
<% budget_subnav_items_for_only_results(budget).each do |item| %>
<% if item[:active] %>
<li class="tabs-title is-active">
<span class="show-for-sr"><%= t("shared.you_are_in") %></span>
Expand All @@ -15,3 +15,4 @@
</ul>
</div>
</div>
<!--budget_subnav_items_for-->
40 changes: 23 additions & 17 deletions app/views/budgets/results/_results_table.html.erb
Expand Up @@ -10,18 +10,19 @@
<th scope="col">
<%= t("budgets.results.investment_title") %>
</th>
<th scope="col" class="text-center">
<%= @budget.id < 5 ? t("budgets.results.ballot_lines_count") : t("budgets.results.voters") %>
</th>
<%if @budget.id >= 5%>
<%if @budget.id < 5%>
<th scope="col" class="text-center">
<%= t("budgets.results.ballot_lines_count_positive") %>
<%= t("budgets.results.ballot_lines_count")%>
</th>
<%else%>
<th scope="col" class="text-center">
<%= t("budgets.results.ballot_lines_count_negative") %>
<%= t("budgets.results.ballot_lines_count_total") %>
</th>
<th scope="col" class="text-center">
<%= t("budgets.results.ballot_lines_count_total") %>
<%= t("budgets.results.ballot_lines_count_positive") %>
</th>
<th scope="col" class="text-center">
<%= t("budgets.results.ballot_lines_count_negative") %>
</th>
<%end%>
<th scope="col" class="text-center min-width-100">
Expand All @@ -38,7 +39,7 @@

<tbody>
<% amount_available = heading_price %>
<% investments.each do |investment| %>
<% investments.order(result_balloting_votes: :desc).each do |investment| %>
<tr id="<%= dom_id(investment) %>"
class="budget-investments <%= investment.winner? ? "success" : "js-discarded" %>"
style="<%= investment.winner? ? "" : "display: none" %>">
Expand All @@ -58,28 +59,33 @@
<% end %>
<%= link_to investment.title, budget_investment_path(@budget, investment) %>
</td>
<td class="text-center">
<%= investment.ballot_lines_count %>
</td>
<%if investment.budget.id >= 5%>
<%if investment.budget.id < 5%>
<td class="text-center">
<%= investment.ballot_lines_up_votes %>
<%= investment.ballot_lines_count %>
</td>
<%else%>
<td class="text-center">
<%= investment.ballot_lines_down_votes %>
<%= investment.ballot_lines_total_votes %>
</td>
<td class="text-center">
<%= investment.ballot_lines_total_votes %>
<%= investment.ballot_lines_up_votes %>
</td>
<td class="text-center">
<%= investment.ballot_lines_down_votes %>
</td>
<%end%>
<td class="text-center">
<%= @budget.formatted_amount(investment.price.to_i !=0 ? investment.price : investment.total_amount) %>
</td>
<% if results_type == :compatible %>
<td class="small text-right"
title="<%= @budget.formatted_amount(amount_available) %> - <%= @budget.formatted_amount(investment.price.to_i !=0 ? investment.price.to_i : investment.total_amount.to_i) %>">
<%= @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%>
</td>
<% end %>
</tr>
Expand Down
@@ -0,0 +1,5 @@
class AddResultBallotingVotesToBudgetInvestments < ActiveRecord::Migration[5.0]
def change
add_column :budget_investments, :result_balloting_votes, :float
end
end
8 changes: 7 additions & 1 deletion lib/tasks/import_data.rake
Expand Up @@ -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

Expand Down

0 comments on commit b7e5ea4

Please sign in to comment.