feat(procedure): validate external links
This commit is contained in:
parent
a43c3fd19d
commit
7136c96a36
13 changed files with 133 additions and 17 deletions
|
@ -234,6 +234,8 @@ class Procedure < ApplicationRecord
|
|||
scope :opendata, -> { where(opendata: true) }
|
||||
scope :publiees_ou_closes, -> { where(aasm_state: [:publiee, :close, :depubliee]) }
|
||||
|
||||
scope :with_external_urls, -> { where.not(lien_notice: [nil, '']).or(where.not(lien_dpo: [nil, ''])) }
|
||||
|
||||
scope :publiques, -> do
|
||||
publiees_ou_closes
|
||||
.opendata
|
||||
|
@ -294,7 +296,12 @@ class Procedure < ApplicationRecord
|
|||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :administrateurs, presence: true
|
||||
|
||||
validates :lien_site_web, presence: true, if: :publiee?
|
||||
validates :lien_notice, url: { no_local: true, allow_blank: true }
|
||||
validates :lien_dpo, format: { with: Devise.email_regexp, message: "n'est pas valide" }, if: :lien_dpo_email?
|
||||
validates :lien_dpo, url: { no_local: true, allow_blank: true }, unless: :lien_dpo_email?
|
||||
|
||||
validates :draft_types_de_champ_public,
|
||||
'types_de_champ/no_empty_block': true,
|
||||
'types_de_champ/no_empty_drop_down': true,
|
||||
|
@ -320,7 +327,6 @@ class Procedure < ApplicationRecord
|
|||
less_than_or_equal_to: 60
|
||||
}
|
||||
|
||||
validates :lien_dpo, email_or_link: true, allow_nil: true
|
||||
validates_with MonAvisEmbedValidator
|
||||
|
||||
validates_associated :draft_revision, on: :publication
|
||||
|
@ -978,6 +984,10 @@ class Procedure < ApplicationRecord
|
|||
update!(routing_enabled: self.groupe_instructeurs.active.many?)
|
||||
end
|
||||
|
||||
def lien_dpo_email?
|
||||
lien_dpo.present? && lien_dpo.match?(/@/)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_auto_archive_on_in_the_future
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue