Add basic frontend for budget executions list
This commit is contained in:
39
app/controllers/budgets/executions_controller.rb
Normal file
39
app/controllers/budgets/executions_controller.rb
Normal 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
|
||||||
@@ -22,7 +22,7 @@ module Abilities
|
|||||||
can [:read], Budget
|
can [:read], Budget
|
||||||
can [:read], Budget::Group
|
can [:read], Budget::Group
|
||||||
can [:read, :print, :json_data], Budget::Investment
|
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 :new, DirectMessage
|
||||||
can [:read, :debate, :draft_publication, :allegations, :result_publication, :proposals], Legislation::Process, published: true
|
can [:read, :debate, :draft_publication, :allegations, :result_publication, :proposals], Legislation::Process, published: true
|
||||||
can [:read, :changes, :go_to_version], Legislation::DraftVersion
|
can [:read, :changes, :go_to_version], Legislation::DraftVersion
|
||||||
|
|||||||
64
app/views/budgets/executions/show.html.erb
Normal file
64
app/views/budgets/executions/show.html.erb
Normal file
@@ -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 %>
|
||||||
|
|
||||||
|
<div class="budgets-stats">
|
||||||
|
<div class="expanded no-margin-top padding header">
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= back_link_to budgets_path %>
|
||||||
|
<h2 class="margin-top">
|
||||||
|
<%= t('budgets.executions.heading') %><br>
|
||||||
|
<span><%= @budget.name %></span>
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row margin-top">
|
||||||
|
<div class="small-12 column">
|
||||||
|
<ul class="tabs">
|
||||||
|
<li class="tabs-title">
|
||||||
|
<%= link_to t('budgets.results.link'), budget_results_path(@budget) %>
|
||||||
|
</li>
|
||||||
|
<li class="tabs-title is-active">
|
||||||
|
<%= link_to t('budgets.executions.link'), budget_executions_path(@budget), class: 'is-active' %>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="small-12 medium-3 large-2 column">
|
||||||
|
<h3 class="margin-bottom">
|
||||||
|
<%= t('budgets.executions.heading_selection_title') %>
|
||||||
|
</h3>
|
||||||
|
<ul class="menu vertical no-margin-top no-padding-top">
|
||||||
|
<% @budget.headings.order('id ASC').each do |heading| %>
|
||||||
|
<li>
|
||||||
|
<%= link_to heading.name,
|
||||||
|
custom_budget_heading_execution_path(@budget, heading_id: heading.to_param),
|
||||||
|
heading.to_param == @heading.to_param ? { class: 'is-active' } : {} %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-12 medium-9 large-10 column">
|
||||||
|
<%= form_tag(budget_executions_path(budget: @budget), method: :get) do %>
|
||||||
|
<div class="small-12 medium-3 column">
|
||||||
|
<%= select_tag 'status', options_from_collection_for_select(@statuses, 'id', 'name') %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -176,6 +176,9 @@ en:
|
|||||||
not_selected_investment_proyects: List of all investment projects not selected for balloting
|
not_selected_investment_proyects: List of all investment projects not selected for balloting
|
||||||
executions:
|
executions:
|
||||||
link: "Execution"
|
link: "Execution"
|
||||||
|
page_title: "%{budget} - Executions"
|
||||||
|
heading: "Participatory budget executions"
|
||||||
|
heading_selection_title: "By district"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "Start date can't be equal or later than End date"
|
dates_range_invalid: "Start date can't be equal or later than End date"
|
||||||
|
|||||||
@@ -176,6 +176,9 @@ es:
|
|||||||
not_selected_investment_proyects: Ver lista de proyectos de gasto no seleccionados para la votación final
|
not_selected_investment_proyects: Ver lista de proyectos de gasto no seleccionados para la votación final
|
||||||
executions:
|
executions:
|
||||||
link: "Ejecución"
|
link: "Ejecución"
|
||||||
|
page_title: "%{budget} - Ejecuciones"
|
||||||
|
heading: "Ejecuciones presupuestos participativos"
|
||||||
|
heading_selection_title: "Ámbito de actuación"
|
||||||
phases:
|
phases:
|
||||||
errors:
|
errors:
|
||||||
dates_range_invalid: "La fecha de comienzo no puede ser igual o superior a la de finalización"
|
dates_range_invalid: "La fecha de comienzo no puede ser igual o superior a la de finalización"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ resources :budgets, only: [:show, :index] do
|
|||||||
end
|
end
|
||||||
|
|
||||||
resource :results, only: :show, controller: "budgets/results"
|
resource :results, only: :show, controller: "budgets/results"
|
||||||
|
resource :executions, only: :show, controller: 'budgets/executions'
|
||||||
end
|
end
|
||||||
|
|
||||||
scope '/participatory_budget' do
|
scope '/participatory_budget' do
|
||||||
|
|||||||
Reference in New Issue
Block a user