app: remove leftovers of procedure path autocomplete

We used to pre-validate the procedure, to display in advance if the path
could be used.

Now that the path autocomplete is long gone, we can remove this kludgy
code.
This commit is contained in:
Pierre de La Morinerie 2021-11-09 11:39:50 +01:00
parent 4fc224490e
commit 2227dcc1e7
2 changed files with 1 additions and 23 deletions

View file

@ -235,7 +235,6 @@ class Procedure < ApplicationRecord
validates :description, presence: true, allow_blank: false, allow_nil: false validates :description, presence: true, allow_blank: false, allow_nil: false
validates :administrateurs, presence: true validates :administrateurs, presence: true
validates :lien_site_web, presence: true, if: :publiee? validates :lien_site_web, presence: true, if: :publiee?
validate :validate_for_publication, on: :publication
validate :check_juridique validate :check_juridique
validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,200}\z/ }, uniqueness: { scope: [:path, :closed_at, :hidden_at, :unpublished_at], case_sensitive: false } validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,200}\z/ }, uniqueness: { scope: [:path, :closed_at, :hidden_at, :unpublished_at], case_sensitive: false }
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION } validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }
@ -325,18 +324,6 @@ class Procedure < ApplicationRecord
end end
end end
def validate_for_publication
old_attributes = self.slice(:aasm_state, :closed_at)
self.aasm_state = :publiee
self.closed_at = nil
is_valid = validate
self.attributes = old_attributes
is_valid
end
def suggested_path(administrateur) def suggested_path(administrateur)
if path_customized? if path_customized?
return path return path

View file

@ -30,14 +30,5 @@
autocomplete: 'off', autocomplete: 'off',
placeholder: 'https://exemple.gouv.fr/ma_demarche') placeholder: 'https://exemple.gouv.fr/ma_demarche')
- procedure.validate(:publication)
- errors = procedure.errors
-# Ignore the :taken error if the path can be claimed
- if errors.details[:path]&.pluck(:error)&.include?(:taken) && procedure.path_available?(administrateur, procedure.path)
- errors.delete(:path)
- options = { class: "button primary", id: 'publish' }
- if errors.details[:path].present?
- options[:disabled] = :disabled
.flex.justify-end .flex.justify-end
= submit_tag procedure_publish_label(procedure, :submit), options = submit_tag procedure_publish_label(procedure, :submit), { class: "button primary", id: 'publish' }