refactor(attestation_template): remove from revisions
This commit is contained in:
parent
c73b650f85
commit
405d2a695f
6 changed files with 3 additions and 117 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
[]
|
||||
|
|
|
@ -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])
|
|
@ -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?
|
||||
|
|
|
@ -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é
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue