diff --git a/app/models/dossier.rb b/app/models/dossier.rb index b14893c5e..aaf93e14f 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -175,8 +175,16 @@ class Dossier < ApplicationRecord :user, :individual, :followers_instructeurs, - :avis, :traitements, + :groupe_instructeur, + procedure: [ + :groupe_instructeurs, + :draft_types_de_champ, + :draft_types_de_champ_private, + :published_types_de_champ, + :published_types_de_champ_private + ], + avis: [:claimant, :expert], etablissement: :champ, champs: { type_de_champ: [], @@ -195,8 +203,7 @@ class Dossier < ApplicationRecord type_de_champ: [], piece_justificative_file_attachment: :blob ] - }, - procedure: :groupe_instructeurs + } ).order(en_construction_at: 'asc') } scope :en_cours, -> { not_archived.state_en_construction_ou_instruction } diff --git a/app/models/procedure.rb b/app/models/procedure.rb index aef21aef0..d4d6ab103 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -66,9 +66,6 @@ class Procedure < ApplicationRecord has_many :draft_types_de_champ, through: :draft_revision, source: :types_de_champ has_many :draft_types_de_champ_private, through: :draft_revision, source: :types_de_champ_private - has_many :all_types_de_champ, -> { joins(:procedure).where('types_de_champ.revision_id != procedures.draft_revision_id') }, through: :revisions, source: :types_de_champ - has_many :all_types_de_champ_private, -> { joins(:procedure).where('types_de_champ.revision_id != procedures.draft_revision_id') }, through: :revisions, source: :types_de_champ_private - has_many :experts_procedures, dependent: :destroy has_many :experts, through: :experts_procedures @@ -92,31 +89,11 @@ class Procedure < ApplicationRecord end def types_de_champ_for_export - if brouillon? - draft_types_de_champ.reject(&:exclude_from_export?) - else - all_types_de_champ - .uniq - .reject(&:exclude_from_export?) - .filter(&:active_revision?) - .group_by(&:stable_id).values.map do |types_de_champ| - types_de_champ.sort_by(&:created_at).last - end - end + types_de_champ.reject(&:exclude_from_export?) end def types_de_champ_private_for_export - if brouillon? - draft_types_de_champ_private - else - all_types_de_champ_private - .uniq - .reject(&:exclude_from_export?) - .filter(&:active_revision?) - .group_by(&:stable_id).values.map do |types_de_champ| - types_de_champ.sort_by(&:created_at).last - end - end + types_de_champ_private.reject(&:exclude_from_export?) end has_many :administrateurs_procedures @@ -596,7 +573,7 @@ class Procedure < ApplicationRecord end def routee? - groupe_instructeurs.count > 1 + groupe_instructeurs.size > 1 end def defaut_groupe_instructeur_for_new_dossier diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index aeed93e2d..913975f58 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -206,10 +206,6 @@ class TypeDeChamp < ApplicationRecord !private? end - def active_revision? - revisions.include?(procedure.active_revision) - end - def self.type_champ_to_class_name(type_champ) "TypesDeChamp::#{type_champ.classify}TypeDeChamp" end