Error 403 when admin would edit a procedure with at least one dossier
This commit is contained in:
parent
5d4a36e6c3
commit
43779aafee
11 changed files with 65 additions and 32 deletions
|
@ -4,4 +4,17 @@ class AdminController < ApplicationController
|
|||
def index
|
||||
redirect_to (admin_procedures_path)
|
||||
end
|
||||
|
||||
def retrieve_procedure
|
||||
id = params[:procedure_id] || params[:id ]
|
||||
|
||||
@procedure = current_administrateur.procedures.find(id)
|
||||
|
||||
unless @procedure.dossiers.count == 0
|
||||
render json: {message: 'Procedure locked'}, status: 403
|
||||
end
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render json: {message: 'Procedure not found'}, status: 404
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue