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']
|
2024-04-01 07:36:14 +02:00
|
|
|
|
# TODO: if: -> { validate_champ_value? || validation_context == :prefill }
|
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
|
|
|
|
|
|
2024-04-02 17:05:44 +02:00
|
|
|
|
def for_export(path = :value)
|
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
|