Rename @budget to @current budget at budget index

Clear instance variable names help understand what's going around when
you're deep 2 or 3 partials. In this case @budget is only used to carry
around the current_budget so @current_budget is more descriptive.

Using `current_budget` directly around would be an alternative, but
maybe not as maintainable in case we want to change which budget is
being shown (for example the drafting one if you're admin).
This commit is contained in:
Bertocq
2018-01-23 23:55:37 +01:00
parent e62ca48a94
commit 791f081a91
3 changed files with 17 additions and 17 deletions

View File

@@ -15,7 +15,7 @@ class BudgetsController < ApplicationController
def index
@finished_budgets = @budgets.finished.order(created_at: :desc)
@budget = current_budget
@current_budget = current_budget
@budgets_coordinates = current_budget_map_locations
end

View File

@@ -1,6 +1,6 @@
<ul class="no-bullet budget-timeline">
<% @budget.published_phases.each do |phase| %>
<li class="phase <%= 'active' if phase == @budget.current_phase %>">
<% @current_budget.published_phases.each do |phase| %>
<li class="phase <%= 'active' if phase == @current_budget.current_phase %>">
<h3><%= t("budgets.phase.#{phase.kind}") %></h3>
<span>
<%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %>

View File

@@ -7,9 +7,9 @@
<div class="row" data-equalizer data-equalizer-on="medium">
<div class="small-12 medium-9 column padding" data-equalizer-watch>
<h1><%= @budget.name %></h1>
<h1><%= @current_budget.name %></h1>
<div class="description">
<%= safe_html_with_links(@budget.description) %>
<%= safe_html_with_links(@current_budget.description) %>
</div>
<p>
<%= link_to t("budgets.index.section_header.help"), "#section_help" %>
@@ -19,11 +19,11 @@
<p>
<strong><%= t('budgets.show.phase') %></strong>
</p>
<h2><%= t("budgets.phase.#{@budget.phase}") %></h2>
<h2><%= t("budgets.phase.#{@current_budget.phase}") %></h2>
<%= link_to t("budgets.index.section_header.all_phases"), "#all_phases" %>
<% if @budget.accepting? %>
<% if @current_budget.accepting? %>
<% if current_user %>
<% if current_user.level_two_or_three_verified? %>
<%= link_to t("budgets.investments.index.sidebar.create"),
@@ -48,9 +48,9 @@
<% end %>
<% if @budget.finished? || (@budget.balloting? && can?(:read_results, @budget)) %>
<% if @current_budget.finished? || (@current_budget.balloting? && can?(:read_results, @current_budget)) %>
<%= link_to t("budgets.show.see_results"),
budget_results_path(@budget, heading_id: @budget.headings.first),
budget_results_path(@current_budget, heading_id: @current_budget.headings.first),
class: "button margin-top expanded" %>
<% end %>
</div>
@@ -62,18 +62,18 @@
<div class="small-12 column">
<div id="groups_and_headings" class="groups-and-headings">
<% @budget.groups.each do |group| %>
<% @current_budget.groups.each do |group| %>
<h2><%= group.name %></h2>
<ul class="no-bullet">
<% group.headings.order_by_group_name.each do |heading| %>
<li class="heading small-12 medium-4 large-2">
<% unless @budget.informing? %>
<%= link_to budget_investments_path(@budget.id, heading_id: heading.id) do %>
<%= heading_name_and_price_html(heading, @budget) %>
<%= link_to budget_investments_path(@current_budget.id, heading_id: heading.id) do %>
<%= heading_name_and_price_html(heading, @current_budget) %>
<% end %>
<% else %>
<div>
<%= heading_name_and_price_html(heading, @budget) %>
<%= heading_name_and_price_html(heading, @current_budget) %>
</div>
<% end %>
</li>
@@ -89,13 +89,13 @@
</div>
<p>
<%= link_to budget_investments_path(@budget.id) do %>
<%= link_to budget_investments_path(@current_budget.id) do %>
<small><%= t("budgets.index.investment_proyects") %></small>
<% end %><br>
<%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unfeasible') do %>
<%= link_to budget_investments_path(budget_id: @current_budget.id, filter: 'unfeasible') do %>
<small><%= t("budgets.index.unfeasible_investment_proyects") %></small>
<% end %><br>
<%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unselected') do %>
<%= link_to budget_investments_path(budget_id: @current_budget.id, filter: 'unselected') do %>
<small><%= t("budgets.index.not_selected_investment_proyects") %></small>
<% end %>
</p>
@@ -103,7 +103,7 @@
<div id="all_phases">
<h2><%= t("budgets.index.all_phases") %></h2>
<%= render "phases" %>
<%= render "phases", budget: @current_budget %>
</div>
</div>
</div>