Add Budgets Stats Controller, route and ability on reviewing ballots and finished budget

This commit is contained in:
Bertocq
2017-06-28 23:54:05 +02:00
committed by Javi Martín
parent 63631f29a8
commit e0e02b47c0
3 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
module Budgets
class StatsController < ApplicationController
load_and_authorize_resource :budget
def show
authorize! :read_stats, @budget
@stats = load_stats
end
private
def load_stats
Budget::Stats.new(@budget).generate
end
end
end

View File

@@ -21,6 +21,7 @@ module Abilities
can [:read], Budget::Group
can [:read, :print, :json_data], Budget::Investment
can [:read_results, :read_executions], Budget, phase: "finished"
can :read_stats, Budget, phase: ["reviewing_ballots", "finished"]
can :new, DirectMessage
can [:read, :debate, :draft_publication, :allegations, :result_publication,
:proposals, :milestones], Legislation::Process, published: true

View File

@@ -15,6 +15,7 @@ resources :budgets, only: [:show, :index] do
end
resource :results, only: :show, controller: "budgets/results"
resource :stats, only: :show, controller: "budgets/stats"
resource :executions, only: :show, controller: "budgets/executions"
end