Fix support tasks
This commit is contained in:
parent
23d8f0d803
commit
31d9b388ab
2 changed files with 4 additions and 7 deletions
|
@ -260,8 +260,8 @@ module Tasks
|
|||
end
|
||||
|
||||
def check_same_administrateur
|
||||
if @source_procedure.administrateur != @destination_procedure.administrateur
|
||||
raise "Mismatching administrateurs #{@source_procedure.administrateur&.email} → #{@destination_procedure.administrateur&.email}"
|
||||
if @source_procedure.administrateur_ids.sort != @destination_procedure.administrateur_ids.sort
|
||||
raise "Mismatching administrateurs #{@source_procedure.administrateurs.pluck(:email)} → #{@destination_procedure.administrateurs.pluck(:email)}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,10 +25,8 @@ namespace :support do
|
|||
procedure_id = ENV['PROCEDURE_ID']
|
||||
procedure = Procedure.find(procedure_id)
|
||||
|
||||
rake_puts("Changing owner of procedure ##{procedure_id} from ##{procedure.administrateur_id} to ##{new_owner.id}")
|
||||
procedure.administrateurs.delete(procedure.administrateur)
|
||||
rake_puts("Changing owner of procedure ##{procedure_id} from ##{procedure.administrateurs.first.id} to ##{new_owner.id}")
|
||||
procedure.administrateurs << new_owner
|
||||
procedure.update(administrateur: new_owner)
|
||||
end
|
||||
|
||||
desc <<~EOD
|
||||
|
@ -71,10 +69,9 @@ namespace :support do
|
|||
end
|
||||
|
||||
procedures.each do |procedure|
|
||||
procedure.administrateurs.delete(procedure.administrateur)
|
||||
procedure.administrateurs.delete(old_owner)
|
||||
procedure.administrateurs << new_owner
|
||||
end
|
||||
procedures.update_all(administrateur_id: new_owner.id)
|
||||
end
|
||||
|
||||
desc <<~EOD
|
||||
|
|
Loading…
Reference in a new issue