Merge pull request #10641 from demarches-simplifiees/move-image-treatment-to-jobs
Technique : déplace les traitements d‘images côté jobs
This commit is contained in:
commit
969706163b
15 changed files with 142 additions and 85 deletions
|
@ -106,7 +106,8 @@ class AttestationTemplate < ApplicationRecord
|
|||
|
||||
def logo_url
|
||||
if logo.attached?
|
||||
Rails.application.routes.url_helpers.url_for(logo)
|
||||
logo_variant = logo.variant(resize_to_limit: [400, 400])
|
||||
logo_variant.key.present? ? logo_variant.processed.url : Rails.application.routes.url_helpers.url_for(logo)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module BlobImageProcessorConcern
|
|||
end
|
||||
|
||||
def representation_required?
|
||||
from_champ? || from_messagerie?
|
||||
from_champ? || from_messagerie? || logo? || from_action_text?
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -23,6 +23,14 @@ module BlobImageProcessorConcern
|
|||
attachments.any? { _1.record.class == Commentaire }
|
||||
end
|
||||
|
||||
def logo?
|
||||
attachments.any? { _1.name == 'logo' }
|
||||
end
|
||||
|
||||
def from_action_text?
|
||||
attachments.any? { _1.record.class == ActionText::RichText }
|
||||
end
|
||||
|
||||
def watermark_required?
|
||||
attachments.any? { _1.record.class == Champs::TitreIdentiteChamp }
|
||||
end
|
||||
|
|
|
@ -146,9 +146,7 @@ class Procedure < ApplicationRecord
|
|||
|
||||
belongs_to :defaut_groupe_instructeur, class_name: 'GroupeInstructeur', inverse_of: false, optional: true
|
||||
|
||||
has_one_attached :logo do |attachable|
|
||||
attachable.variant :email, resize_to_limit: [450, 450]
|
||||
end
|
||||
has_one_attached :logo
|
||||
has_one_attached :notice
|
||||
has_one_attached :deliberation
|
||||
|
||||
|
@ -679,7 +677,8 @@ class Procedure < ApplicationRecord
|
|||
|
||||
def logo_url
|
||||
if logo.attached?
|
||||
Rails.application.routes.url_helpers.url_for(logo)
|
||||
logo_variant = logo.variant(resize_to_limit: [400, 400])
|
||||
logo_variant.key.present? ? logo_variant.processed.url : Rails.application.routes.url_helpers.url_for(logo)
|
||||
else
|
||||
ActionController::Base.helpers.image_url(PROCEDURE_DEFAULT_LOGO_SRC)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue