Merge pull request #2399 from tchak/remove-references-to-test-procedures
Remove references to `test_procedure`
This commit is contained in:
commit
559984c351
2 changed files with 7 additions and 25 deletions
|
@ -9,6 +9,7 @@ class Procedure < ApplicationRecord
|
|||
|
||||
has_one :module_api_carto, dependent: :destroy
|
||||
has_one :attestation_template, dependent: :destroy
|
||||
has_one :procedure_path
|
||||
|
||||
belongs_to :administrateur
|
||||
belongs_to :parent_procedure, class_name: 'Procedure'
|
||||
|
@ -105,7 +106,7 @@ class Procedure < ApplicationRecord
|
|||
def after_hide
|
||||
now = Time.now
|
||||
update(hidden_at: now)
|
||||
procedure_path&.hide!(self)
|
||||
procedure_path&.hide!
|
||||
dossiers.update_all(hidden_at: now)
|
||||
end
|
||||
|
||||
|
@ -153,10 +154,6 @@ class Procedure < ApplicationRecord
|
|||
Dossier.new(procedure: self, champs: champs, champs_private: champs_private)
|
||||
end
|
||||
|
||||
def procedure_path
|
||||
ProcedurePath.find_with_procedure(self)
|
||||
end
|
||||
|
||||
def path
|
||||
procedure_path.path if procedure_path.present?
|
||||
end
|
||||
|
|
|
@ -3,32 +3,17 @@ class ProcedurePath < ApplicationRecord
|
|||
validates :administrateur_id, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :procedure_id, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
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
|
||||
|
||||
def hide!(new_procedure)
|
||||
if procedure == new_procedure
|
||||
update(procedure: nil)
|
||||
end
|
||||
if test_procedure == new_procedure
|
||||
update(test_procedure: nil)
|
||||
end
|
||||
if procedure.nil? && test_procedure.nil?
|
||||
destroy
|
||||
end
|
||||
def hide!
|
||||
destroy!
|
||||
end
|
||||
|
||||
def publish!(new_procedure)
|
||||
if procedure != new_procedure
|
||||
if procedure&.publiee?
|
||||
procedure.archive!
|
||||
end
|
||||
update(procedure: new_procedure)
|
||||
if procedure&.publiee?
|
||||
procedure.archive!
|
||||
end
|
||||
update!(procedure: new_procedure)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue