diff --git a/app/dashboards/procedure_dashboard.rb b/app/dashboards/procedure_dashboard.rb index 87eff4600..dc7c3681d 100644 --- a/app/dashboards/procedure_dashboard.rb +++ b/app/dashboards/procedure_dashboard.rb @@ -12,7 +12,6 @@ class ProcedureDashboard < Administrate::BaseDashboard types_de_champ: TypesDeChampCollectionField, path: ProcedureLinkField, dossiers: Field::HasMany, - procedure_path: Field::HasOne, administrateur: Field::BelongsTo, id: Field::Number, libelle: Field::String, diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 1a6e41566..bae4d72f3 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -4,8 +4,6 @@ class Procedure < ApplicationRecord has_many :types_de_champ_private, -> { private_only }, class_name: 'TypeDeChamp', dependent: :destroy has_many :dossiers - has_one :procedure_path, dependent: :destroy - has_one :module_api_carto, dependent: :destroy has_one :attestation_template, dependent: :destroy @@ -61,6 +59,10 @@ class Procedure < ApplicationRecord Dossier.new(procedure: self, champs: champs, champs_private: champs_private) end + def procedure_path + ProcedurePath.find_with_procedure(self) + end + def hide! now = DateTime.now self.update(hidden_at: now, aasm_state: :hidden) diff --git a/app/models/procedure_path.rb b/app/models/procedure_path.rb index bfe75ef04..5b6ca20c2 100644 --- a/app/models/procedure_path.rb +++ b/app/models/procedure_path.rb @@ -6,4 +6,8 @@ class ProcedurePath < ApplicationRecord belongs_to :test_procedure, class_name: 'Procedure' belongs_to :procedure belongs_to :administrateur + + def self.find_with_procedure(procedure) + where(procedure: procedure).or(where(test_procedure: procedure)).last + end end