EQT instructeur, je peux supprimer un dossier terminé

This commit is contained in:
kara Diaby 2020-11-17 13:25:35 +01:00 committed by simon lehericey
parent f7f832bed8
commit 00b5ad7a10
18 changed files with 255 additions and 97 deletions

View file

@ -520,6 +520,16 @@ class Dossier < ApplicationRecord
end
end
def deleted_by_instructeur_and_keep_track!(author)
if keep_track_on_deletion?
deleted_dossier = DeletedDossier.create_from_dossier(self, :instructeur_request)
self.delete_operations_logs
log_dossier_operation(author, :supprime_par_instructeur, self)
DossierMailer.notify_instructeur_deletion_to_user(deleted_dossier, user.email).deliver_later
self.destroy
end
end
def discard_and_keep_track!(author, reason)
if keep_track_on_deletion? && en_construction?
deleted_dossier = DeletedDossier.create_from_dossier(self, reason)
@ -797,6 +807,10 @@ class Dossier < ApplicationRecord
private
def delete_operations_logs
DossierOperationLog.where(dossier: self).destroy_all
end
def geo_areas
champs.includes(:geo_areas).flat_map(&:geo_areas) + champs_private.includes(:geo_areas).flat_map(&:geo_areas)
end