Merge pull request #10119 from demarches-simplifiees/add-explanation-when-publish-with-same-url-ldu

ETQ admin j'ai un message d'explication si j'utilise une URL déja utilisée lors de la publication d'une démarche
This commit is contained in:
Lisa Durand 2024-03-20 13:21:59 +00:00 committed by GitHub
commit 6c5c744411
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 69 additions and 15 deletions

View file

@ -395,7 +395,7 @@ class Procedure < ApplicationRecord
slug = libelle&.parameterize&.first(50)
suggestion = slug
counter = 1
while !path_available?(administrateur, suggestion)
while !path_available?(suggestion)
counter = counter + 1
suggestion = "#{slug}-#{counter}"
end
@ -408,10 +408,8 @@ class Procedure < ApplicationRecord
.find_by(path: path)
end
def path_available?(administrateur, path)
procedure = other_procedure_with_path(path)
procedure.blank? || (administrateur.owns?(procedure) && canonical_procedure_child?(procedure))
def path_available?(path)
other_procedure_with_path(path).blank?
end
def canonical_procedure_child?(procedure)