demarches-normaliennes/app/models/champs/piece_justificative_champ.rb
2024-05-06 15:52:06 +02:00

32 lines
835 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class Champs::PieceJustificativeChamp < Champ
FILE_MAX_SIZE = 200.megabytes
has_many_attached :piece_justificative_file do |attachable|
attachable.variant :medium, resize: '400x400'
end
# TODO: if: -> { validate_champ_value? || validation_context == :prefill }
validates :piece_justificative_file,
size: { less_than: FILE_MAX_SIZE },
if: -> { !type_de_champ.skip_pj_validation }
validates :piece_justificative_file,
content_type: AUTHORIZED_CONTENT_TYPES,
if: -> { !type_de_champ.skip_content_type_pj_validation }
def main_value_name
:piece_justificative_file
end
def search_terms
# We dont know how to search inside documents yet
end
def mandatory_blank?
mandatory? && !piece_justificative_file.attached?
end
def blank?
piece_justificative_file.blank?
end
end