Merge pull request #2331 from consul/current-budget-polish
Add current_budget to management controllers
This commit is contained in:
@@ -5,6 +5,7 @@ class Management::BaseController < ActionController::Base
|
||||
before_action :set_locale
|
||||
|
||||
helper_method :managed_user
|
||||
helper_method :current_user
|
||||
|
||||
private
|
||||
|
||||
@@ -40,4 +41,7 @@ class Management::BaseController < ActionController::Base
|
||||
I18n.locale = session[:locale]
|
||||
end
|
||||
|
||||
def current_budget
|
||||
Budget.current
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ class Management::BudgetsController < Management::BaseController
|
||||
end
|
||||
|
||||
def print_investments
|
||||
@budget = Budget.current
|
||||
@budget = current_budget
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -5,7 +5,7 @@ class Valuation::BudgetsController < Valuation::BaseController
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@budget = Budget.current
|
||||
@budget = current_budget
|
||||
if @budget.present?
|
||||
@investments_with_valuation_open = {}
|
||||
@investments_with_valuation_open = @budget.investments
|
||||
|
||||
@@ -33,7 +33,7 @@ class Budget < ActiveRecord::Base
|
||||
scope :open, -> { where.not(phase: "finished") }
|
||||
|
||||
def self.current
|
||||
where.not(phase: "drafting").last
|
||||
where.not(phase: "drafting").order(:created_at).last
|
||||
end
|
||||
|
||||
def current_phase
|
||||
|
||||
Reference in New Issue
Block a user