From 2c8f5d2129d7a7772b88bda3df322609bd02949c Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Tue, 12 Aug 2025 18:40:55 +0300 Subject: [PATCH] debug file --- app/controllers/templates_debug_controller.rb | 27 +++++++++++++++++++ config/locales/i18n.yml | 6 +++++ 2 files changed, 33 insertions(+) diff --git a/app/controllers/templates_debug_controller.rb b/app/controllers/templates_debug_controller.rb index 810c042a..676c2f64 100644 --- a/app/controllers/templates_debug_controller.rb +++ b/app/controllers/templates_debug_controller.rb @@ -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 diff --git a/config/locales/i18n.yml b/config/locales/i18n.yml index cf5cfc97..3243e90c 100644 --- a/config/locales/i18n.yml +++ b/config/locales/i18n.yml @@ -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