refactor delete_user_account task
This commit is contained in:
parent
9a62d3fe0c
commit
c72ce977f7
1 changed files with 2 additions and 4 deletions
|
@ -15,13 +15,11 @@ namespace :support do
|
|||
user = User.find_by!(email: user_email)
|
||||
administration = Administration.find_by!(email: administration_email)
|
||||
|
||||
if user.dossiers.state_instruction_commencee.any?
|
||||
if !user.can_be_deleted?
|
||||
fail "Cannot delete this user because instruction has started for some dossiers"
|
||||
end
|
||||
|
||||
user.dossiers.each do |dossier|
|
||||
dossier.delete_and_keep_track(administration)
|
||||
end
|
||||
user.delete_and_keep_track_dossiers(administration)
|
||||
user.destroy
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue