diff --git a/app/controllers/budgets/executions_controller.rb b/app/controllers/budgets/executions_controller.rb new file mode 100644 index 000000000..d513c3924 --- /dev/null +++ b/app/controllers/budgets/executions_controller.rb @@ -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 diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb index 23cfdc971..18927cc80 100644 --- a/app/models/abilities/everyone.rb +++ b/app/models/abilities/everyone.rb @@ -22,7 +22,7 @@ module Abilities can [:read], Budget can [:read], Budget::Group can [:read, :print, :json_data], Budget::Investment - can :read_results, Budget, phase: "finished" + can [:read_results, :read_executions], Budget, phase: "finished" can :new, DirectMessage can [:read, :debate, :draft_publication, :allegations, :result_publication, :proposals], Legislation::Process, published: true can [:read, :changes, :go_to_version], Legislation::DraftVersion diff --git a/app/views/budgets/executions/show.html.erb b/app/views/budgets/executions/show.html.erb new file mode 100644 index 000000000..8cab9ba10 --- /dev/null +++ b/app/views/budgets/executions/show.html.erb @@ -0,0 +1,64 @@ +<% provide :title, t('budgets.executions.page_title', budget: @budget.name) %> +<% content_for :meta_description do %><%= @budget.description_for_phase('finished') %><% end %> +<% provide :social_media_meta_tags do %> +<%= render 'shared/social_media_meta_tags', + social_url: budget_executions_url(@budget), + social_title: @budget.name, + social_description: @budget.description_for_phase('finished') %> +<% end %> + +<% content_for :canonical do %> + <%= render 'shared/canonical', href: budget_executions_url(@budget) %> +<% end %> + +