add validation on routing_criteria_name

This commit is contained in:
Eric Leroy-Terquem 2022-09-30 11:34:55 +02:00
parent d9e2c89c2f
commit 1177d861f4
2 changed files with 7 additions and 4 deletions

View file

@ -191,10 +191,12 @@ module Administrateurs
end
def update_routing_criteria_name
procedure.update!(routing_criteria_name: routing_criteria_name)
redirect_to admin_procedure_groupe_instructeurs_path(procedure),
notice: "Le libellé est maintenant « #{procedure.routing_criteria_name} »."
if procedure.update(routing_criteria_name: routing_criteria_name)
flash[:notice] = "Le libellé est maintenant « #{procedure.routing_criteria_name} »."
else
flash[:alert] = "Le libellé du routage doit être rempli."
end
redirect_to admin_procedure_groupe_instructeurs_path(procedure)
end
def update_routing_enabled

View file

@ -323,6 +323,7 @@ class Procedure < ApplicationRecord
validates :api_entreprise_token, jwt_token: true, allow_blank: true
validates :api_particulier_token, format: { with: /\A[A-Za-z0-9\-_=.]{15,}\z/ }, allow_blank: true
validates :routing_criteria_name, presence: true, allow_blank: false
before_save :update_juridique_required
after_initialize :ensure_path_exists