chore: generate variant for procedure logo in background
This commit is contained in:
parent
7693d216d8
commit
00c905a615
4 changed files with 16 additions and 7 deletions
|
@ -5,7 +5,12 @@ class ProceduresController < ApplicationController
|
||||||
|
|
||||||
def logo
|
def logo
|
||||||
if @procedure.logo.attached?
|
if @procedure.logo.attached?
|
||||||
redirect_to url_for(@procedure.logo.variant(:email))
|
logo_variant = @procedure.logo.variant(resize_to_limit: [400, 400])
|
||||||
|
if logo_variant.key.present?
|
||||||
|
redirect_to url_for(logo_variant.processed)
|
||||||
|
else
|
||||||
|
redirect_to url_for(@procedure.logo)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
redirect_to ActionController::Base.helpers.image_url(PROCEDURE_DEFAULT_LOGO_SRC)
|
redirect_to ActionController::Base.helpers.image_url(PROCEDURE_DEFAULT_LOGO_SRC)
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,7 +106,8 @@ class AttestationTemplate < ApplicationRecord
|
||||||
|
|
||||||
def logo_url
|
def logo_url
|
||||||
if logo.attached?
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ module BlobImageProcessorConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def representation_required?
|
def representation_required?
|
||||||
from_champ? || from_messagerie?
|
from_champ? || from_messagerie? || is_a_logo?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -23,6 +23,10 @@ module BlobImageProcessorConcern
|
||||||
attachments.any? { _1.record.class == Commentaire }
|
attachments.any? { _1.record.class == Commentaire }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def logo?
|
||||||
|
attachments.any? { _1.name == 'logo' }
|
||||||
|
end
|
||||||
|
|
||||||
def watermark_required?
|
def watermark_required?
|
||||||
attachments.any? { _1.record.class == Champs::TitreIdentiteChamp }
|
attachments.any? { _1.record.class == Champs::TitreIdentiteChamp }
|
||||||
end
|
end
|
||||||
|
|
|
@ -176,9 +176,7 @@ class Procedure < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :defaut_groupe_instructeur, class_name: 'GroupeInstructeur', inverse_of: false, optional: true
|
belongs_to :defaut_groupe_instructeur, class_name: 'GroupeInstructeur', inverse_of: false, optional: true
|
||||||
|
|
||||||
has_one_attached :logo do |attachable|
|
has_one_attached :logo
|
||||||
attachable.variant :email, resize_to_limit: [450, 450]
|
|
||||||
end
|
|
||||||
has_one_attached :notice
|
has_one_attached :notice
|
||||||
has_one_attached :deliberation
|
has_one_attached :deliberation
|
||||||
|
|
||||||
|
@ -705,7 +703,8 @@ class Procedure < ApplicationRecord
|
||||||
|
|
||||||
def logo_url
|
def logo_url
|
||||||
if logo.attached?
|
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
|
else
|
||||||
ActionController::Base.helpers.image_url(PROCEDURE_DEFAULT_LOGO_SRC)
|
ActionController::Base.helpers.image_url(PROCEDURE_DEFAULT_LOGO_SRC)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue