feat(attestation): validate attestation tags

This commit is contained in:
Paul Chavard 2022-11-09 11:10:19 +00:00
parent cafda4f6f0
commit c73b650f85
7 changed files with 21 additions and 2 deletions

View file

@ -2,4 +2,10 @@ class Procedure::Card::AttestationComponent < ApplicationComponent
def initialize(procedure:)
@procedure = procedure
end
private
def error_messages
@procedure.errors.messages_for(:attestation_template).to_sentence
end
end

View file

@ -3,8 +3,12 @@
.fr-tile__body.flex.justify-between
- if @procedure.attestation_template&.activated?
%div
%span.icon.accept
%p.fr-tile-status-accept Activée
- if error_messages.present?
%span.icon.refuse
%p.fr-tile-status-error À modifier
- else
%span.icon.accept
%p.fr-tile-status-accept Activée
- else
%div
%span.icon.clock

View file

@ -23,6 +23,8 @@ class Procedure::PublicationWarningComponent < ApplicationComponent
case attribute
when :draft_revision
champs_admin_procedure_path(@procedure)
when :attestation_template
edit_admin_procedure_attestation_template_path(@procedure)
when :initiated_mail, :received_mail, :closed_mail, :refused_mail, :without_continuation_mail
admin_procedure_mail_templates_path(@procedure)
end

View file

@ -21,6 +21,8 @@ class AttestationTemplate < ApplicationRecord
has_one_attached :logo
has_one_attached :signature
validates :title, tags: true, if: -> { procedure.present? }
validates :body, tags: true, if: -> { procedure.present? }
validates :footer, length: { maximum: 190 }
FILE_MAX_SIZE = 1.megabytes

View file

@ -292,6 +292,7 @@ class Procedure < ApplicationRecord
validates_associated :closed_mail, on: :publication
validates_associated :refused_mail, on: :publication
validates_associated :without_continuation_mail, on: :publication
validates_associated :attestation_template, on: :publication, if: -> { attestation_template&.activated? }
FILE_MAX_SIZE = 20.megabytes
validates :notice, content_type: [

View file

@ -25,6 +25,8 @@ en:
closed_mail: File sorted as accepted notification email
refused_mail: File sorted as refused notification email
without_continuation_mail: File sorted with no further action notification email
attestation_template: Attestation template
draft_revision: The form
errors:
models:
procedure:

View file

@ -25,6 +25,8 @@ fr:
closed_mail: Lemail de notification dacceptation de dossier
refused_mail: Lemail de notification de refus de dossier
without_continuation_mail: Lemail de notification de classement sans suite de dossier
attestation_template: Le modèle d'attestation
draft_revision: Le formulaire
errors:
models:
procedure: