add message when path is already taken when publishing a procedure
This commit is contained in:
parent
5f826cfd88
commit
e757eefd37
12 changed files with 70 additions and 15 deletions
|
@ -387,7 +387,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
|
||||
|
@ -400,10 +400,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue