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-23 14:51:59 +02:00
|
|
|
|
|
|
|
|
|
has_many_attached :piece_justificative_file do |attachable|
|
|
|
|
|
attachable.variant :medium, resize: '400x400'
|
|
|
|
|
end
|
|
|
|
|
|
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
|
2020-09-17 17:09:16 +02:00
|
|
|
|
end
|