We need to check if the budget is in drafting phase to avoid showing it to the users, unless the current user is an administrator.
51 lines
1.3 KiB
Ruby
51 lines
1.3 KiB
Ruby
module BudgetsHelper
|
|
|
|
def budget_phases_select_options
|
|
Budget::PHASES.map { |ph| [ t("budgets.phase.#{ph}"), ph ] }
|
|
end
|
|
|
|
def budget_currency_symbol_select_options
|
|
Budget::CURRENCY_SYMBOLS.map { |cs| [ cs, cs ] }
|
|
end
|
|
|
|
def namespaced_budget_investment_path(investment, options = {})
|
|
case namespace
|
|
when "management/budgets"
|
|
management_budget_investment_path(investment.budget, investment, options)
|
|
else
|
|
budget_investment_path(investment.budget, investment, options)
|
|
end
|
|
end
|
|
|
|
def namespaced_budget_investment_vote_path(investment, options = {})
|
|
case namespace
|
|
when "management/budgets"
|
|
vote_management_budget_investment_path(investment.budget, investment, options)
|
|
else
|
|
vote_budget_investment_path(investment.budget, investment, options)
|
|
end
|
|
end
|
|
|
|
def display_budget_countdown?(budget)
|
|
budget.balloting?
|
|
end
|
|
|
|
def css_for_ballot_heading(heading)
|
|
return '' if current_ballot.blank?
|
|
current_ballot.has_lines_in_heading?(heading) ? 'active' : ''
|
|
end
|
|
|
|
def current_ballot
|
|
Budget::Ballot.where(user: current_user, budget: @budget).first
|
|
end
|
|
|
|
def investment_tags_select_options
|
|
Budget::Investment.tags_on(:valuation).order(:name).select(:name).distinct
|
|
end
|
|
|
|
def budget_published?(budget)
|
|
!budget.drafting? || current_user&.administrator?
|
|
end
|
|
|
|
end
|