fix(attestation): build v2 draft on draft procedure when a v1 is published

This commit is contained in:
Colin Darie 2024-07-29 14:48:19 +02:00
parent 906103255a
commit 2689bc6721
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
2 changed files with 18 additions and 1 deletions

View file

@ -133,7 +133,13 @@ module Administrateurs
@procedure.attestation_templates.build(version: 2, json_body: AttestationTemplate::TIPTAP_BODY_DEFAULT, activated: true, state:)
end
def should_edit_draft? = !@procedure.brouillon?
def should_edit_draft?
if @procedure.brouillon?
@procedure.attestation_templates.v1.published.any?
else
true
end
end
def editor_params
params.required(:attestation_template).permit(:activated, :official_layout, :label_logo, :label_direction, :tiptap_body, :footer, :logo, :signature, :activated, :state)