2020-11-17 16:34:24 +01:00
|
|
|
module BlobTitreIdentiteWatermarkConcern
|
2020-12-10 12:50:40 +01:00
|
|
|
def watermark_pending?
|
|
|
|
watermark_required? && !watermark_done?
|
|
|
|
end
|
|
|
|
|
|
|
|
def watermark_done?
|
2022-12-22 17:57:08 +01:00
|
|
|
watermarked_at.present?
|
2020-11-17 16:34:24 +01:00
|
|
|
end
|
|
|
|
|
2021-03-11 14:42:57 +01:00
|
|
|
def watermark_later
|
2022-12-22 17:57:08 +01:00
|
|
|
if watermark_pending?
|
2020-11-17 16:34:24 +01:00
|
|
|
TitreIdentiteWatermarkJob.perform_later(self)
|
|
|
|
end
|
|
|
|
end
|
2021-03-11 14:42:57 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def watermark_required?
|
2022-12-22 17:57:08 +01:00
|
|
|
attachments.any? { _1.record.class == Champs::TitreIdentiteChamp }
|
2021-03-11 14:42:57 +01:00
|
|
|
end
|
2020-11-17 16:34:24 +01:00
|
|
|
end
|