chore: remove uninterlacing from web machines

This commit is contained in:
Eric Leroy-Terquem 2024-07-24 11:10:24 +02:00
parent 0511a84abf
commit 4d0961d3ec
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605
7 changed files with 1 additions and 53 deletions

View file

@ -2,8 +2,6 @@
module Administrateurs module Administrateurs
class AttestationTemplateV2sController < AdministrateurController class AttestationTemplateV2sController < AdministrateurController
include UninterlacePngConcern
before_action :retrieve_procedure before_action :retrieve_procedure
before_action :ensure_feature_active before_action :ensure_feature_active
before_action :retrieve_attestation_template before_action :retrieve_attestation_template
@ -74,17 +72,6 @@ module Administrateurs
@attestation_template.procedure = @procedure @attestation_template.procedure = @procedure
end end
logo_file = attestation_params.delete(:logo)
signature_file = attestation_params.delete(:signature)
if logo_file
attestation_params[:logo] = uninterlace_png(logo_file)
end
if signature_file
attestation_params[:signature] = uninterlace_png(signature_file)
end
@attestation_template.assign_attributes(attestation_params) @attestation_template.assign_attributes(attestation_params)
if @attestation_template.invalid? if @attestation_template.invalid?

View file

@ -2,8 +2,6 @@
module Administrateurs module Administrateurs
class AttestationTemplatesController < AdministrateurController class AttestationTemplatesController < AdministrateurController
include UninterlacePngConcern
before_action :retrieve_procedure before_action :retrieve_procedure
before_action :preload_revisions before_action :preload_revisions
@ -63,16 +61,6 @@ module Administrateurs
if @activated_attestation_params.nil? if @activated_attestation_params.nil?
@activated_attestation_params = params.require(:attestation_template) @activated_attestation_params = params.require(:attestation_template)
.permit(:title, :body, :footer, :activated, :logo, :signature) .permit(:title, :body, :footer, :activated, :logo, :signature)
logo_file = params['attestation_template'].delete('logo')
signature_file = params['attestation_template'].delete('signature')
if logo_file.present?
@activated_attestation_params[:logo] = uninterlace_png(logo_file)
end
if signature_file.present?
@activated_attestation_params[:signature] = uninterlace_png(signature_file)
end
end end
@activated_attestation_params @activated_attestation_params

View file

@ -5,7 +5,6 @@ module Administrateurs
include ActiveSupport::NumberHelper include ActiveSupport::NumberHelper
include EmailSanitizableConcern include EmailSanitizableConcern
include Logic include Logic
include UninterlacePngConcern
include GroupeInstructeursSignatureConcern include GroupeInstructeursSignatureConcern
before_action :ensure_not_super_admin!, only: [:add_instructeur] before_action :ensure_not_super_admin!, only: [:add_instructeur]

View file

@ -19,9 +19,7 @@ module GroupeInstructeursSignatureConcern
flash[:alert] = "Aucun fichier joint pour le tampon de l'attestation" flash[:alert] = "Aucun fichier joint pour le tampon de l'attestation"
render :show render :show
else else
signature = uninterlace_png(signature_file) if @groupe_instructeur.signature.attach(signature_file)
if @groupe_instructeur.signature.attach(signature)
handle_redirect :success handle_redirect :success
else else
handle_redirect :alert handle_redirect :alert

View file

@ -1,21 +0,0 @@
# frozen_string_literal: true
module UninterlacePngConcern
extend ActiveSupport::Concern
private
def uninterlace_png(uploaded_file)
if uploaded_file&.content_type == 'image/png' && interlaced?(uploaded_file.tempfile.to_path)
chunky_img = ChunkyPNG::Image.from_io(uploaded_file.to_io)
chunky_img.save(uploaded_file.tempfile.to_path, interlace: false)
uploaded_file.tempfile.reopen(uploaded_file.tempfile.to_path, 'rb')
end
uploaded_file
end
def interlaced?(png_path)
png = MiniMagick::Image.open(png_path)
png.data["interlace"] != "None"
end
end

View file

@ -3,7 +3,6 @@
module Instructeurs module Instructeurs
class GroupeInstructeursController < InstructeurController class GroupeInstructeursController < InstructeurController
include EmailSanitizableConcern include EmailSanitizableConcern
include UninterlacePngConcern
include GroupeInstructeursSignatureConcern include GroupeInstructeursSignatureConcern
before_action :ensure_allowed! before_action :ensure_allowed!

View file

@ -8,8 +8,6 @@ describe Administrateurs::AttestationTemplatesController, type: :controller do
let(:logo2) { fixture_file_upload('spec/fixtures/files/white.png', 'image/png') } let(:logo2) { fixture_file_upload('spec/fixtures/files/white.png', 'image/png') }
let(:signature) { fixture_file_upload('spec/fixtures/files/black.png', 'image/png') } let(:signature) { fixture_file_upload('spec/fixtures/files/black.png', 'image/png') }
let(:signature2) { fixture_file_upload('spec/fixtures/files/black.png', 'image/png') } let(:signature2) { fixture_file_upload('spec/fixtures/files/black.png', 'image/png') }
let(:interlaced_logo) { fixture_file_upload('spec/fixtures/files/interlaced-black.png', 'image/png') }
let(:uninterlaced_logo) { fixture_file_upload('spec/fixtures/files/uninterlaced-black.png', 'image/png') }
let(:invalid_logo) { fixture_file_upload('spec/fixtures/files/invalid_file_format.json', 'application/json') } let(:invalid_logo) { fixture_file_upload('spec/fixtures/files/invalid_file_format.json', 'application/json') }
before do before do