2021-11-25 16:26:55 +01:00
|
|
|
module Administrateurs
|
2018-04-13 16:56:00 +02:00
|
|
|
class AdministrateurController < ApplicationController
|
|
|
|
before_action :authenticate_administrateur!
|
2018-11-14 16:24:34 +01:00
|
|
|
|
|
|
|
def retrieve_procedure
|
|
|
|
id = params[:procedure_id] || params[:id]
|
|
|
|
|
|
|
|
@procedure = current_administrateur.procedures.find(id)
|
|
|
|
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
flash.alert = 'Démarche inexistante'
|
2019-09-24 16:38:58 +02:00
|
|
|
redirect_to admin_procedures_path, status: 404
|
2018-11-14 16:24:34 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def procedure_locked?
|
|
|
|
if @procedure.locked?
|
|
|
|
flash.alert = 'Démarche verrouillée'
|
|
|
|
redirect_to admin_procedure_path(@procedure)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-28 15:08:48 +02:00
|
|
|
def procedure_revisable?
|
|
|
|
if @procedure.locked? && !@procedure.feature_enabled?(:procedure_revisions)
|
|
|
|
flash.alert = 'Démarche verrouillée'
|
|
|
|
redirect_to admin_procedure_path(@procedure)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-14 16:24:34 +01:00
|
|
|
def reset_procedure
|
2021-06-24 11:57:05 +02:00
|
|
|
if @procedure.brouillon? || @procedure.draft_changed?
|
2018-11-14 16:24:34 +01:00
|
|
|
@procedure.reset!
|
|
|
|
end
|
|
|
|
end
|
2018-04-13 16:56:00 +02:00
|
|
|
end
|
|
|
|
end
|