chore: remove uninterlacing from web machines
This commit is contained in:
parent
0511a84abf
commit
4d0961d3ec
7 changed files with 1 additions and 53 deletions
|
@ -2,8 +2,6 @@
|
|||
|
||||
module Administrateurs
|
||||
class AttestationTemplateV2sController < AdministrateurController
|
||||
include UninterlacePngConcern
|
||||
|
||||
before_action :retrieve_procedure
|
||||
before_action :ensure_feature_active
|
||||
before_action :retrieve_attestation_template
|
||||
|
@ -74,17 +72,6 @@ module Administrateurs
|
|||
@attestation_template.procedure = @procedure
|
||||
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)
|
||||
|
||||
if @attestation_template.invalid?
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
module Administrateurs
|
||||
class AttestationTemplatesController < AdministrateurController
|
||||
include UninterlacePngConcern
|
||||
|
||||
before_action :retrieve_procedure
|
||||
before_action :preload_revisions
|
||||
|
||||
|
@ -63,16 +61,6 @@ module Administrateurs
|
|||
if @activated_attestation_params.nil?
|
||||
@activated_attestation_params = params.require(:attestation_template)
|
||||
.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
|
||||
|
||||
@activated_attestation_params
|
||||
|
|
|
@ -5,7 +5,6 @@ module Administrateurs
|
|||
include ActiveSupport::NumberHelper
|
||||
include EmailSanitizableConcern
|
||||
include Logic
|
||||
include UninterlacePngConcern
|
||||
include GroupeInstructeursSignatureConcern
|
||||
|
||||
before_action :ensure_not_super_admin!, only: [:add_instructeur]
|
||||
|
|
|
@ -19,9 +19,7 @@ module GroupeInstructeursSignatureConcern
|
|||
flash[:alert] = "Aucun fichier joint pour le tampon de l'attestation"
|
||||
render :show
|
||||
else
|
||||
signature = uninterlace_png(signature_file)
|
||||
|
||||
if @groupe_instructeur.signature.attach(signature)
|
||||
if @groupe_instructeur.signature.attach(signature_file)
|
||||
handle_redirect :success
|
||||
else
|
||||
handle_redirect :alert
|
||||
|
|
|
@ -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
|
|
@ -3,7 +3,6 @@
|
|||
module Instructeurs
|
||||
class GroupeInstructeursController < InstructeurController
|
||||
include EmailSanitizableConcern
|
||||
include UninterlacePngConcern
|
||||
include GroupeInstructeursSignatureConcern
|
||||
|
||||
before_action :ensure_allowed!
|
||||
|
|
|
@ -8,8 +8,6 @@ describe Administrateurs::AttestationTemplatesController, type: :controller do
|
|||
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(: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') }
|
||||
|
||||
before do
|
||||
|
|
Loading…
Reference in a new issue