From 03f4fce2dd13aef6428f65f588f195d54dbc9695 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 8 Jan 2018 22:56:47 +0100 Subject: [PATCH] Add budget_published? helper method to BudgetHelper 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. --- app/helpers/budgets_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index fefda85ab..3b4c81f7e 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -42,4 +42,9 @@ module BudgetsHelper 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