2017-06-29 15:30:42 +02:00
|
|
|
module NewGestionnaire
|
|
|
|
class ProceduresController < GestionnaireController
|
2017-07-03 14:05:55 +02:00
|
|
|
layout "new_application"
|
|
|
|
|
|
|
|
before_action :ensure_ownership!, except: [:index]
|
|
|
|
|
|
|
|
def index
|
|
|
|
@procedures = current_gestionnaire.procedures
|
|
|
|
|
|
|
|
dossiers = current_gestionnaire.dossiers.state_not_brouillon
|
|
|
|
@dossiers_count_per_procedure = dossiers.group(:procedure_id).count
|
|
|
|
@dossiers_nouveaux_count_per_procedure = dossiers.state_nouveaux.group(:procedure_id).count
|
|
|
|
@dossiers_archived_count_per_procedure = dossiers.archived.group(:procedure_id).count
|
|
|
|
|
|
|
|
@followed_dossiers_count_per_procedure = current_gestionnaire.followed_dossiers.where(procedure: @procedures).group(:procedure_id).count
|
|
|
|
end
|
2017-06-29 15:30:42 +02:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def procedure
|
|
|
|
Procedure.find(params[:procedure_id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def ensure_ownership!
|
|
|
|
if !procedure.gestionnaires.include?(current_gestionnaire)
|
|
|
|
flash[:alert] = "Vous n'avez pas accès à cette procédure"
|
|
|
|
redirect_to root_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|