Revert "Revert "4127 fix superadmin supprime compte usager""
This reverts commit 751f24f7bb
.
This commit is contained in:
parent
a82cf22b71
commit
cee4c5b8fb
13 changed files with 150 additions and 22 deletions
|
@ -97,7 +97,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def can_be_deleted?
|
||||
dossiers.state_instruction_commencee.empty?
|
||||
administrateur.nil? && instructeur.nil? && dossiers.state_instruction_commencee.empty?
|
||||
end
|
||||
|
||||
def delete_and_keep_track_dossiers(administration)
|
||||
|
@ -105,12 +105,11 @@ class User < ApplicationRecord
|
|||
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)
|
||||
end
|
||||
destroy
|
||||
dossiers.each do |dossier|
|
||||
dossier.delete_and_keep_track(administration)
|
||||
end
|
||||
dossiers.unscoped.destroy_all
|
||||
destroy!
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue