diff --git a/app/models/concerns/dossier_rebase_concern.rb b/app/models/concerns/dossier_rebase_concern.rb index 4cefce3f3..afe2e4c12 100644 --- a/app/models/concerns/dossier_rebase_concern.rb +++ b/app/models/concerns/dossier_rebase_concern.rb @@ -29,7 +29,7 @@ module DossierRebaseConcern end def accepted_en_construction_change?(change) - if change[:model] == :attestation_template || change[:op] == :move || change[:op] == :remove + if change[:op] == :move || change[:op] == :remove true elsif change[:op] == :update case change[:attribute] @@ -46,7 +46,7 @@ module DossierRebaseConcern end def accepted_en_instruction_change?(change) - change[:model] == :attestation_template + false end def rebase diff --git a/app/models/procedure_revision.rb b/app/models/procedure_revision.rb index 8c550594b..dee9a65cd 100644 --- a/app/models/procedure_revision.rb +++ b/app/models/procedure_revision.rb @@ -140,14 +140,12 @@ class ProcedureRevision < ApplicationRecord end def different_from?(revision) - revision_types_de_champ != revision.revision_types_de_champ || - attestation_template != revision.attestation_template + revision_types_de_champ != revision.revision_types_de_champ end def compare(revision) changes = [] changes += compare_revision_types_de_champ(revision_types_de_champ, revision.revision_types_de_champ) - changes += compare_attestation_template(attestation_template, revision.attestation_template) changes end @@ -240,63 +238,6 @@ class ProcedureRevision < ApplicationRecord end end - def compare_attestation_template(from_at, to_at) - changes = [] - if from_at.nil? && to_at.present? - changes << { - model: :attestation_template, - op: :add - } - elsif to_at.present? - if from_at.title != to_at.title - changes << { - model: :attestation_template, - op: :update, - attribute: :title, - from: from_at.title, - to: to_at.title - } - end - if from_at.body != to_at.body - changes << { - model: :attestation_template, - op: :update, - attribute: :body, - from: from_at.body, - to: to_at.body - } - end - if from_at.footer != to_at.footer - changes << { - model: :attestation_template, - op: :update, - attribute: :footer, - from: from_at.footer, - to: to_at.footer - } - end - if from_at.logo_checksum != to_at.logo_checksum - changes << { - model: :attestation_template, - op: :update, - attribute: :logo, - from: from_at.logo_filename, - to: to_at.logo_filename - } - end - if from_at.signature_checksum != to_at.signature_checksum - changes << { - model: :attestation_template, - op: :update, - attribute: :signature, - from: from_at.signature_filename, - to: to_at.signature_filename - } - end - end - changes - end - def compare_revision_types_de_champ(from_coordinates, to_coordinates) if from_coordinates == to_coordinates [] diff --git a/app/views/administrateurs/procedures/_revision_change_attestation_template.html.haml b/app/views/administrateurs/procedures/_revision_change_attestation_template.html.haml deleted file mode 100644 index c4f085f3d..000000000 --- a/app/views/administrateurs/procedures/_revision_change_attestation_template.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -- case change[:op] -- when :add - - list.with_item do - = t(:add, scope: [:administrateurs, :revision_changes, :attestation_template]) -- when :update - - case change[:attribute] - - when :title - - list.with_item do - = t(:update_title, scope: [:administrateurs, :revision_changes, :attestation_template], to: change[:to]) - - when :body - - list.with_item do - = t(:update_body, scope: [:administrateurs, :revision_changes, :attestation_template]) - - when :footer - - list.with_item do - = t(:update_footer, scope: [:administrateurs, :revision_changes, :attestation_template]) - - when :logo - - list.with_item do - = t(:update_logo, scope: [:administrateurs, :revision_changes, :attestation_template], to: change[:to]) - - when :signature - - list.with_item do - = t(:update_signature, scope: [:administrateurs, :revision_changes, :attestation_template], to: change[:to]) diff --git a/app/views/administrateurs/procedures/_revision_changes.html.haml b/app/views/administrateurs/procedures/_revision_changes.html.haml index 3c9cc72da..cc34e6567 100644 --- a/app/views/administrateurs/procedures/_revision_changes.html.haml +++ b/app/views/administrateurs/procedures/_revision_changes.html.haml @@ -2,7 +2,6 @@ - list.with_empty do = t(:no_changes, scope: [:administrateurs, :revision_changes]) - = render partial: 'administrateurs/procedures/revision_change_attestation_template', collection: changes.filter { |change| change[:model] == :attestation_template }, as: :change, locals: { list: list } = render partial: "administrateurs/procedures/revision_change_type_de_champ", collection: changes.filter { |change| change[:model] == :type_de_champ }, as: :change, locals: { list: list } - move_changes, move_private_changes = changes.filter { |change| change[:op] == :move }.partition { |change| !change[:private] } - if move_changes.present? diff --git a/config/locales/views/administrateurs/revision_changes/fr.yml b/config/locales/views/administrateurs/revision_changes/fr.yml index 3972a6264..05485fc65 100644 --- a/config/locales/views/administrateurs/revision_changes/fr.yml +++ b/config/locales/views/administrateurs/revision_changes/fr.yml @@ -2,13 +2,6 @@ fr: administrateurs: revision_changes: no_changes: Aucune modification - attestation_template: - add: Un model d’attestation à été ajouté - update_title: Le titre de l’attestation à été modifié. Le nouveau titre est « %{to} » - update_body: Le corps du document de l’attestation à été modifié - update_footer: Le pied de page de l’attestation à été modifié - update_logo: Le logo de l’attestation à été modifié. Le nouveau logo est « %{to} » - update_signature: La signature de l’attestation à été modifié. La nouvelle signature est « %{to} » has_changes: Modifications en cours (appliqué à la prochaine publication) add: Le champ « %{label} » a été ajouté remove: Le champ « %{label} » a été supprimé diff --git a/spec/models/dossier_rebase_concern_spec.rb b/spec/models/dossier_rebase_concern_spec.rb index 098cd8950..f2332bda3 100644 --- a/spec/models/dossier_rebase_concern_spec.rb +++ b/spec/models/dossier_rebase_concern_spec.rb @@ -70,19 +70,6 @@ describe Dossier do expect(dossier.can_rebase?).to be_truthy end end - - context 'with attestation template changes' do - before do - attestation_template.update(title: "Test") - procedure.publish_revision! - dossier.reload - end - - it 'should be true' do - expect(dossier.pending_changes).not_to be_empty - expect(dossier.can_rebase?).to be_truthy - end - end end context 'en_instruction' do @@ -123,19 +110,6 @@ describe Dossier do end end - context 'with attestation template changes' do - before do - attestation_template.update(title: "Test") - procedure.publish_revision! - dossier.reload - end - - it 'should be true' do - expect(dossier.pending_changes).not_to be_empty - expect(dossier.can_rebase?).to be_truthy - end - end - context 'with type de champ made optional' do before do procedure.draft_revision.find_and_ensure_exclusive_use(mandatory_type_de_champ.stable_id).update(mandatory: false)