Revert "4127 fix superadmin supprime compte usager"
This commit is contained in:
parent
65a78b682f
commit
751f24f7bb
13 changed files with 22 additions and 150 deletions
|
@ -97,7 +97,7 @@ class User < ApplicationRecord
|
|||
end
|
||||
|
||||
def can_be_deleted?
|
||||
administrateur.nil? && instructeur.nil? && dossiers.state_instruction_commencee.empty?
|
||||
dossiers.state_instruction_commencee.empty?
|
||||
end
|
||||
|
||||
def delete_and_keep_track_dossiers(administration)
|
||||
|
@ -105,11 +105,12 @@ class User < ApplicationRecord
|
|||
raise "Cannot delete this user because instruction has started for some dossiers"
|
||||
end
|
||||
|
||||
dossiers.each do |dossier|
|
||||
dossier.delete_and_keep_track(administration)
|
||||
if can_be_deleted?
|
||||
dossiers.each do |dossier|
|
||||
dossier.delete_and_keep_track(administration)
|
||||
end
|
||||
destroy
|
||||
end
|
||||
dossiers.unscoped.destroy_all
|
||||
destroy!
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue