diff --git a/app/controllers/budgets/groups_controller.rb b/app/controllers/budgets/groups_controller.rb new file mode 100644 index 000000000..e55974a6a --- /dev/null +++ b/app/controllers/budgets/groups_controller.rb @@ -0,0 +1,10 @@ +module Budgets + class GroupsController < ApplicationController + load_and_authorize_resource :budget + load_and_authorize_resource :group, class: "Budget::Group" + + def show + end + + end +end \ No newline at end of file diff --git a/app/helpers/budget_helper.rb b/app/helpers/budget_helper.rb index 745ea88f6..af239f074 100644 --- a/app/helpers/budget_helper.rb +++ b/app/helpers/budget_helper.rb @@ -24,4 +24,13 @@ module BudgetHelper def display_budget_countdown?(budget) budget.balloting? end + + def css_for_ballot_heading(heading) + return '' unless current_ballot.present? + current_ballot.has_lines_in_heading?(heading) ? 'active' : '' + end + + def current_ballot + Budget::Ballot.where(user: current_user, budget: @budget).first + end end diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb index 30c1c3b55..cf8af477b 100644 --- a/app/models/abilities/everyone.rb +++ b/app/models/abilities/everyone.rb @@ -13,6 +13,7 @@ module Abilities can :read, User can [:search, :read], Annotation can [:read], Budget + can [:read], Budget::Group can [:read], Budget::Investment can :new, DirectMessage end diff --git a/app/models/budget/ballot.rb b/app/models/budget/ballot.rb index 848e2f22d..b28c7d859 100644 --- a/app/models/budget/ballot.rb +++ b/app/models/budget/ballot.rb @@ -40,6 +40,10 @@ class Budget self.heading_id.present? end + def has_lines_in_heading?(heading) + investments.by_heading(heading.id).any? + end + def has_investment?(investment) self.investment_ids.include?(investment.id) end diff --git a/app/views/budgets/groups/show.html.erb b/app/views/budgets/groups/show.html.erb new file mode 100644 index 000000000..8f9f9ae86 --- /dev/null +++ b/app/views/budgets/groups/show.html.erb @@ -0,0 +1,28 @@ +
| <%= t('budget.show.heading') %> | -<%= t('budget.show.price') %> | -
|---|---|
| - <%= link_to t('budget.show.no_heading'), budget_investments_path(budget_id: @budget.id, heading_id: nil) %> - | -- <%# format_price(@budget, @budget.price) %> - | -
| - <%= link_to heading.name, budget_investments_path(budget_id: @budget.id, heading_id: heading.id) %> - | -- <%= format_price(@budget, heading.price) %> + <%= link_to group.name, budget_group_path(@budget, group) %> |