Revert "Merge pull request #9002 from tchak/feat-procedure-clone-preview-published"
This reverts commit7a6f46a8ad
, reversing changes made to4513c52213
.
This commit is contained in:
parent
6033792669
commit
6148f24387
3 changed files with 15 additions and 35 deletions
|
@ -60,12 +60,7 @@ module Administrateurs
|
||||||
end
|
end
|
||||||
|
|
||||||
def apercu
|
def apercu
|
||||||
revision = if current_administrateur.owns?(procedure_without_control)
|
@dossier = procedure_without_control.draft_revision.dossier_for_preview(current_user)
|
||||||
procedure_without_control.draft_revision
|
|
||||||
else
|
|
||||||
procedure_without_control.active_revision
|
|
||||||
end
|
|
||||||
@dossier = revision.dossier_for_preview(current_user)
|
|
||||||
@tab = apercu_tab
|
@tab = apercu_tab
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -177,8 +172,13 @@ module Administrateurs
|
||||||
flash.notice = 'Démarche clonée, pensez a vérifier la Présentation et choisir le service a laquelle cette procédure est associé.'
|
flash.notice = 'Démarche clonée, pensez a vérifier la Présentation et choisir le service a laquelle cette procédure est associé.'
|
||||||
redirect_to admin_procedure_path(id: new_procedure.id)
|
redirect_to admin_procedure_path(id: new_procedure.id)
|
||||||
else
|
else
|
||||||
|
if cloned_from_library?
|
||||||
flash.alert = new_procedure.errors.full_messages
|
flash.alert = new_procedure.errors.full_messages
|
||||||
redirect_back(fallback_location: admin_procedures_path)
|
redirect_to new_from_existing_admin_procedures_path
|
||||||
|
else
|
||||||
|
flash.alert = new_procedure.errors.full_messages
|
||||||
|
redirect_to admin_procedures_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
|
|
@ -521,17 +521,13 @@ class Procedure < ApplicationRecord
|
||||||
is_different_admin = !admin.owns?(self)
|
is_different_admin = !admin.owns?(self)
|
||||||
|
|
||||||
populate_champ_stable_ids
|
populate_champ_stable_ids
|
||||||
|
include_list = {
|
||||||
revision_to_clone = if is_different_admin && published_revision_id.present?
|
attestation_template: [],
|
||||||
:published_revision
|
draft_revision: {
|
||||||
else
|
|
||||||
:draft_revision
|
|
||||||
end
|
|
||||||
include_list = { attestation_template: [] }
|
|
||||||
include_list[revision_to_clone] = {
|
|
||||||
revision_types_de_champ: [:type_de_champ],
|
revision_types_de_champ: [:type_de_champ],
|
||||||
dossier_submitted_message: []
|
dossier_submitted_message: []
|
||||||
}
|
}
|
||||||
|
}
|
||||||
include_list[:groupe_instructeurs] = :instructeurs if !is_different_admin
|
include_list[:groupe_instructeurs] = :instructeurs if !is_different_admin
|
||||||
procedure = self.deep_clone(include: include_list) do |original, kopy|
|
procedure = self.deep_clone(include: include_list) do |original, kopy|
|
||||||
PiecesJustificativesService.clone_attachments(original, kopy)
|
PiecesJustificativesService.clone_attachments(original, kopy)
|
||||||
|
@ -549,12 +545,8 @@ class Procedure < ApplicationRecord
|
||||||
procedure.max_duree_conservation_dossiers_dans_ds = NEW_MAX_DUREE_CONSERVATION
|
procedure.max_duree_conservation_dossiers_dans_ds = NEW_MAX_DUREE_CONSERVATION
|
||||||
end
|
end
|
||||||
procedure.estimated_dossiers_count = 0
|
procedure.estimated_dossiers_count = 0
|
||||||
if procedure.published_revision.present?
|
|
||||||
procedure.draft_revision = procedure.published_revision
|
|
||||||
end
|
|
||||||
procedure.draft_revision.procedure = procedure
|
|
||||||
procedure.draft_revision.published_at = nil
|
|
||||||
procedure.published_revision = nil
|
procedure.published_revision = nil
|
||||||
|
procedure.draft_revision.procedure = procedure
|
||||||
|
|
||||||
if is_different_admin
|
if is_different_admin
|
||||||
procedure.administrateurs = [admin]
|
procedure.administrateurs = [admin]
|
||||||
|
|
|
@ -675,18 +675,6 @@ describe Procedure do
|
||||||
expect(subject.groupe_instructeurs.first.label).to eq(GroupeInstructeur::DEFAUT_LABEL)
|
expect(subject.groupe_instructeurs.first.label).to eq(GroupeInstructeur::DEFAUT_LABEL)
|
||||||
expect(subject.groupe_instructeurs.first.instructeurs.size).to eq(0)
|
expect(subject.groupe_instructeurs.first.instructeurs.size).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when published' do
|
|
||||||
before { procedure.publish! }
|
|
||||||
|
|
||||||
it 'should clone published revision as draft' do
|
|
||||||
expect(procedure.revisions.size).to eq(2)
|
|
||||||
expect(procedure.published_revision).not_to be_nil
|
|
||||||
expect(subject.published_revision).to be_nil
|
|
||||||
expect(subject.draft_revision.published_at).to be_nil
|
|
||||||
expect(subject.draft_revision.types_de_champ.first.stable_id).to eq(procedure.published_revision.types_de_champ.first.stable_id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should duplicate existing mail_templates' do
|
it 'should duplicate existing mail_templates' do
|
||||||
|
|
Loading…
Reference in a new issue