Add basic frontend for budget executions list

This commit is contained in:
Angel Perez
2018-06-28 09:26:50 -04:00
committed by Javi Martín
parent b483ca7f7e
commit 3e6cbc9505
6 changed files with 111 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
module Budgets
class ExecutionsController < ApplicationController
before_action :load_budget
before_action :load_heading
before_action :load_investments
load_and_authorize_resource :budget
def show
authorize! :read_executions, @budget
@statuses = ::Budget::Investment::Status.all
end
private
def load_budget
@budget = Budget.find_by(slug: params[:id]) || Budget.find_by(id: params[:id])
end
def load_heading
@heading = if params[:heading_id].present?
@budget.headings.find_by(slug: params[:heading_id])
else
@heading = @budget.headings.first
end
end
def load_investments
@investments = Budget::Result.new(@budget, @heading).investments.joins(:milestones)
if params[:status].present?
@investments.where('budget_investment_milestones.status_id = ?', params[:status])
else
@investments
end
end
end
end