Add annuaire_education champ

This commit is contained in:
Paul Chavard 2021-01-14 17:29:57 +01:00
parent 5c9f2e8783
commit 54f2084aef
8 changed files with 55 additions and 1 deletions

View file

@ -1256,6 +1256,11 @@ enum TypeDeChamp {
"""
address
"""
Annuaire de léducation
"""
annuaire_education
"""
Carte
"""

View file

@ -0,0 +1,35 @@
# == Schema Information
#
# Table name: champs
#
# id :integer not null, primary key
# data :jsonb
# private :boolean default(FALSE), not null
# row :integer
# type :string
# value :string
# created_at :datetime
# updated_at :datetime
# dossier_id :integer
# etablissement_id :integer
# parent_id :bigint
# type_de_champ_id :integer
#
class Champs::AnnuaireEducationChamp < Champs::TextChamp
before_save :cleanup_if_empty
after_update_commit :fetch_data
private
def cleanup_if_empty
if value_changed?
self.data = nil
end
end
def fetch_data
if value.present? && data.nil?
AnnuaireEducationUpdateJob.perform_later(self)
end
end
end

View file

@ -47,7 +47,8 @@ class TypeDeChamp < ApplicationRecord
carte: 'carte',
repetition: 'repetition',
titre_identite: 'titre_identite',
iban: 'iban'
iban: 'iban',
annuaire_education: 'annuaire_education'
}
belongs_to :revision, class_name: 'ProcedureRevision', optional: true

View file

@ -0,0 +1,2 @@
class TypesDeChamp::AnnuaireEducationTypeDeChamp < TypesDeChamp::TextTypeDeChamp
end