Add Budgets Stats Controller, route and ability on reviewing ballots and finished budget
This commit is contained in:
18
app/controllers/budgets/stats_controller.rb
Normal file
18
app/controllers/budgets/stats_controller.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user