2020-09-17 17:09:16 +02:00
|
|
|
|
# == Schema Information
|
|
|
|
|
#
|
|
|
|
|
# Table name: champs
|
|
|
|
|
#
|
2021-02-04 19:23:40 +01:00
|
|
|
|
# id :integer not null, primary key
|
|
|
|
|
# data :jsonb
|
|
|
|
|
# fetch_external_data_exceptions :string is an Array
|
2022-12-01 12:00:21 +01:00
|
|
|
|
# prefilled :boolean default(FALSE)
|
2021-02-04 19:23:40 +01:00
|
|
|
|
# private :boolean default(FALSE), not null
|
2021-10-20 17:26:09 +02:00
|
|
|
|
# rebased_at :datetime
|
2021-02-04 19:23:40 +01:00
|
|
|
|
# type :string
|
|
|
|
|
# value :string
|
2021-10-05 15:37:13 +02:00
|
|
|
|
# value_json :jsonb
|
2021-02-04 19:23:40 +01:00
|
|
|
|
# created_at :datetime
|
|
|
|
|
# updated_at :datetime
|
2022-09-21 15:20:42 +02:00
|
|
|
|
# dossier_id :integer
|
2021-02-04 19:23:40 +01:00
|
|
|
|
# etablissement_id :integer
|
|
|
|
|
# external_id :string
|
|
|
|
|
# parent_id :bigint
|
2022-12-16 12:39:51 +01:00
|
|
|
|
# row_id :string
|
2022-09-21 15:20:42 +02:00
|
|
|
|
# type_de_champ_id :integer
|
2020-09-17 17:09:16 +02:00
|
|
|
|
#
|
|
|
|
|
class Champs::TitreIdentiteChamp < Champ
|
2021-09-14 18:03:40 +02:00
|
|
|
|
FILE_MAX_SIZE = 20.megabytes
|
2022-11-21 17:53:29 +01:00
|
|
|
|
ACCEPTED_FORMATS = ['image/png', 'image/jpeg']
|
2021-11-24 10:04:20 +01:00
|
|
|
|
validates :piece_justificative_file, content_type: ACCEPTED_FORMATS, size: { less_than: FILE_MAX_SIZE }
|
2020-09-17 17:09:16 +02:00
|
|
|
|
|
|
|
|
|
def main_value_name
|
|
|
|
|
:piece_justificative_file
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def search_terms
|
|
|
|
|
# We don’t know how to search inside documents yet
|
|
|
|
|
end
|
|
|
|
|
|
2022-10-17 10:38:23 +02:00
|
|
|
|
def mandatory_blank?
|
2022-08-08 17:17:52 +02:00
|
|
|
|
mandatory? && !piece_justificative_file.attached?
|
2020-09-17 17:09:16 +02:00
|
|
|
|
end
|
|
|
|
|
|
2023-06-27 17:38:37 +02:00
|
|
|
|
def blank?
|
|
|
|
|
piece_justificative_file.blank?
|
|
|
|
|
end
|
|
|
|
|
|
2020-09-17 17:09:16 +02:00
|
|
|
|
def for_export
|
2022-11-08 16:46:57 +01:00
|
|
|
|
piece_justificative_file.attached? ? "présent" : "absent"
|
2020-09-17 17:09:16 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def for_api
|
2022-11-08 18:00:28 +01:00
|
|
|
|
nil
|
2020-09-17 17:09:16 +02:00
|
|
|
|
end
|
|
|
|
|
end
|