raise if trying to del a user who can't be deleted

This commit is contained in:
Christophe Robillard 2020-01-08 17:00:00 +01:00 committed by clemkeirua
parent 696a058280
commit 0f881f942b
3 changed files with 6 additions and 9 deletions

View file

@ -101,6 +101,10 @@ class User < ApplicationRecord
end
def delete_and_keep_track_dossiers(administration)
if !can_be_deleted?
raise "Cannot delete this user because instruction has started for some dossiers"
end
if can_be_deleted?
dossiers.each do |dossier|
dossier.delete_and_keep_track(administration)