fix(data): update procedures with invalid mon avis

This commit is contained in:
Eric Leroy-Terquem 2024-03-14 18:14:57 +01:00
parent 94f37b6708
commit 0a00d801bc
2 changed files with 17 additions and 2 deletions

View file

@ -0,0 +1,15 @@
# frozen_string_literal: true
module Maintenance
class DisableRemainingInvalidMonAvisTask < MaintenanceTasks::Task
def collection
# rubocop:disable DS/Unscoped
Procedure.unscoped.where.not(monavis_embed: nil)
# rubocop:enable DS/Unscoped
end
def process(procedure)
procedure.update_column(:monavis_embed, '') if !procedure.valid? && procedure.errors.key?(:monavis_embed)
end
end
end

View file

@ -13,9 +13,9 @@ class MonAvisEmbedValidator < ActiveModel::Validator
check_img(embed.css('img')) check_img(embed.css('img'))
end end
rescue MonAvisEmbedError => e rescue MonAvisEmbedError => e
record.errors.add :base, :invalid, message: "Le code fourni ne correspond pas au format des codes MonAvis reconnus par la plateforme. #{e.message}" record.errors.add :monavis_embed, :invalid, message: "Le code fourni ne correspond pas au format des codes MonAvis reconnus par la plateforme. #{e.message}"
rescue # nokogiri rescue # nokogiri
record.errors.add :base, :invalid, message: "Le code fourni ne correspond pas au format des codes MonAvis reconnus par la plateforme." record.errors.add :monavis_embed, :invalid, message: "Le code fourni ne correspond pas au format des codes MonAvis reconnus par la plateforme."
end end
def check_link(links) def check_link(links)