debug file

This commit is contained in:
Pete Matsyburka
2025-08-12 18:40:55 +03:00
parent 2bffbf83c6
commit 2c8f5d2129
2 changed files with 33 additions and 0 deletions
@@ -3,6 +3,8 @@
class TemplatesDebugController < ApplicationController
load_and_authorize_resource :template
DEBUG_FILE = ''
def show
attachment = @template.documents.first
@@ -16,6 +18,8 @@ class TemplatesDebugController < ApplicationController
@template.update!(fields: Templates::ProcessDocument.normalize_attachment_fields(@template, [attachment]))
debug_file if DEBUG_FILE.present?
ActiveRecord::Associations::Preloader.new(
records: [@template],
associations: [schema_documents: { preview_images_attachments: :blob }]
@@ -31,4 +35,27 @@ class TemplatesDebugController < ApplicationController
render 'templates/edit', layout: 'plain'
end
def debug_file
tempfile = Tempfile.new
tempfile.binmode
tempfile.write(File.read(DEBUG_FILE))
tempfile.rewind
filename = File.basename(DEBUG_FILE)
file = ActionDispatch::Http::UploadedFile.new(
tempfile:,
filename:,
type: Marcel::MimeType.for(tempfile)
)
params = { files: [file] }
documents = Templates::CreateAttachments.call(@template, params)
schema = documents.map { |doc| { attachment_uuid: doc.uuid, name: doc.filename.base } }
@template.update!(schema:)
end
end
+6
View File
@@ -24,6 +24,7 @@ en: &en
thanks: Thanks
private: Private
select: Select
party: Party
edit_order: Edit Order
invite_form_fields: Invite form fields
default_parties: Default parties
@@ -899,6 +900,7 @@ en: &en
range_without_total: "%{from}-%{to} events"
es: &es
party: Parte
edit_order: Edita Pedido
select: Seleccionar
invite_form_fields: Invitar campos del formulario
@@ -1778,6 +1780,7 @@ es: &es
range_without_total: "%{from}-%{to} eventos"
it: &it
party: Parte
edit_order: Modifica Ordine
select: Seleziona
invite_form_fields: Invita campi modulo
@@ -2657,6 +2660,7 @@ it: &it
range_without_total: "%{from}-%{to} eventi"
fr: &fr
party: Partie
edit_order: Modifier la commande
select: Sélectionner
invite_form_fields: Inviter des champs de formulaire
@@ -3539,6 +3543,7 @@ fr: &fr
range_without_total: "%{from} à %{to} événements"
pt: &pt
party: Parte
edit_order: Edita Pedido
select: Selecionar
invite_form_fields: Convidar campos do formulário
@@ -4419,6 +4424,7 @@ pt: &pt
range_without_total: "%{from}-%{to} eventos"
de: &de
party: Partei
edit_order: Bestellung bearbeiten
select: Auswählen
invite_form_fields: Formularfelder einladen