From b5051a25d9f34c22c9fe81642126da60e441a607 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 2 Sep 2024 16:47:34 +0200 Subject: [PATCH] it displays an alert if using test service before publishing a procedure --- app/models/concerns/initiation_procedure_concern.rb | 2 +- app/models/procedure.rb | 8 ++++++++ app/models/service.rb | 2 ++ .../administrateurs/procedures/publication.html.haml | 2 ++ config/locales/views/administrateurs/procedures/en.yml | 2 +- config/locales/views/administrateurs/procedures/fr.yml | 2 +- 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/initiation_procedure_concern.rb b/app/models/concerns/initiation_procedure_concern.rb index 38a3d8f74..7f67c2481 100644 --- a/app/models/concerns/initiation_procedure_concern.rb +++ b/app/models/concerns/initiation_procedure_concern.rb @@ -30,7 +30,7 @@ module InitiationProcedureConcern telephone: '1234', horaires: 'de 9 h à 18 h', adresse: 'adresse', - siret: '35600082800018', + siret: Service::SIRET_TEST, etablissement_infos: { adresse: "75 rue du Louvre\n75002\nPARIS\nFRANCE" }, etablissement_lat: 48.87, etablissement_lng: 2.34, diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 43512a928..7b96d03f8 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -706,6 +706,10 @@ class Procedure < ApplicationRecord result << :service end + if service_test? + result << :service + end + if missing_instructeurs? result << :instructeurs end @@ -737,6 +741,10 @@ class Procedure < ApplicationRecord end end + def service_test? + service&.siret == Service::SIRET_TEST + end + def revised? revisions.size > 2 end diff --git a/app/models/service.rb b/app/models/service.rb index 77816ad27..78f15b777 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -6,6 +6,8 @@ class Service < ApplicationRecord scope :ordered, -> { order(nom: :asc) } + SIRET_TEST = '35600082800018' + enum type_organisme: { administration_centrale: 'administration_centrale', association: 'association', diff --git a/app/views/administrateurs/procedures/publication.html.haml b/app/views/administrateurs/procedures/publication.html.haml index 95513ddbf..6549a22fd 100644 --- a/app/views/administrateurs/procedures/publication.html.haml +++ b/app/views/administrateurs/procedures/publication.html.haml @@ -46,6 +46,8 @@ %li= link_to("des instructeurs", admin_procedure_groupe_instructeur_path(@procedure, @procedure.defaut_groupe_instructeur)) - if @procedure.service.nil? %li= link_to("un service", admin_services_path(procedure_id: @procedure)) + - if @procedure.service_test? + %li= link_to("un service valide", admin_services_path(procedure_id: @procedure)) = link_to t('.back_to_procedure'), admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-arrow-go-back-line fr-mt-2w' - else diff --git a/config/locales/views/administrateurs/procedures/en.yml b/config/locales/views/administrateurs/procedures/en.yml index 0f043ce36..c1776e841 100644 --- a/config/locales/views/administrateurs/procedures/en.yml +++ b/config/locales/views/administrateurs/procedures/en.yml @@ -47,7 +47,7 @@ en: published_procedure_html: "This procedure is published, some elements can no longer be modified. To access it you can use the link:" public_link_procedure_html: "Be careful, always post the full link displayed above, and not a generic link to %{link}" missing_information_title: missing information - missing_information_content: "To be able to test this procedure, you must first assign it:" + missing_information_content: "To be able to publish this procedure, you must first assign it:" missing_information_service: You must provide the contact details of your Administrative Department before you can publish your procedure. missing_information_instructeurs: You must assign instructors before you can publish your procedure. missing_link: This procedure does not yet have a link, and is not accessible to the public. diff --git a/config/locales/views/administrateurs/procedures/fr.yml b/config/locales/views/administrateurs/procedures/fr.yml index 320daad34..f86a93276 100644 --- a/config/locales/views/administrateurs/procedures/fr.yml +++ b/config/locales/views/administrateurs/procedures/fr.yml @@ -47,7 +47,7 @@ fr: published_procedure_html: "Cette démarche est publiée, certains éléments ne peuvent plus être modifiés. Pour y accéder vous pouvez utiliser le lien :" public_link_procedure_html: "Attention, diffusez toujours le lien complet affiché ci-dessus, et non pas un lien générique vers %{link}" missing_information_title: informations manquantes - missing_information_content: "Pour pouvoir tester cette démarche, vous devez d’abord lui affecter :" + missing_information_content: "Pour pouvoir publier cette démarche, vous devez d’abord lui affecter :" missing_information_service: Vous devez renseigner les coordonnées de votre Service administratif avant de pouvoir publier votre démarche. missing_information_instructeurs: Vous devez affecter des instructeurs avant de pouvoir publier votre démarche. missing_link: Cette démarche n’a pas encore de lien, et n’est pas accessible par le public.