From 77fc5920a2d1800d9bda8757a41a33c7a0bde5a3 Mon Sep 17 00:00:00 2001 From: Shiro-Nek0 Date: Wed, 11 Mar 2026 15:59:50 -0300 Subject: [PATCH 1/2] image export like db --- app.py | 28 ++++++++++++++++++++++++++++ templates/macros/navbar.html | 5 +++++ 2 files changed, 33 insertions(+) diff --git a/app.py b/app.py index 933f186..8feba2f 100644 --- a/app.py +++ b/app.py @@ -10,6 +10,9 @@ import mimetypes import time import uuid from datetime import datetime +import zipfile +import io + # from dotenv import load_dotenv # load_dotenv() @@ -532,6 +535,31 @@ def export_db(): return send_file(DB_FILE, as_attachment=True, download_name=f"SekiPOS_Backup_{datetime.now().strftime('%Y%m%d')}.db", mimetype='application/x-sqlite3') return "Error: Database file not found", 404 +@app.route('/export/images') +@login_required +def export_images(): + if not os.path.exists(CACHE_DIR) or not os.listdir(CACHE_DIR): + return "No images found to export", 404 + + # Create an in-memory byte stream to hold the zip data + memory_file = io.BytesIO() + + with zipfile.ZipFile(memory_file, 'w', zipfile.ZIP_DEFLATED) as zf: + for root, dirs, files in os.walk(CACHE_DIR): + for file in files: + file_path = os.path.join(root, file) + # Store files using their names only to avoid nesting inside the zip + zf.write(file_path, arcname=file) + + memory_file.seek(0) + + return send_file( + memory_file, + mimetype='application/zip', + as_attachment=True, + download_name=f"SekiPOS_Images_{datetime.now().strftime('%Y%m%d')}.zip" + ) + # @app.route('/process_payment', methods=['POST']) # @login_required # def process_payment(): diff --git a/templates/macros/navbar.html b/templates/macros/navbar.html index 368f398..18e2f38 100644 --- a/templates/macros/navbar.html +++ b/templates/macros/navbar.html @@ -37,6 +37,11 @@ Descargar DB +
  • + + Descargar Imágenes + +
  • From 1a048a0e074ee26bd45dda9731c78c2ecef42fba Mon Sep 17 00:00:00 2001 From: SekiDesu01 Date: Wed, 11 Mar 2026 16:52:17 -0300 Subject: [PATCH 2/2] Fixed recepit lenght --- migrate.py | 10 +++++----- templates/macros/modals.html | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/migrate.py b/migrate.py index aedae21..0e56022 100644 --- a/migrate.py +++ b/migrate.py @@ -6,12 +6,12 @@ def upgrade_db(): try: with sqlite3.connect(DB_FILE) as conn: # Add stock column - conn.execute("ALTER TABLE products ADD COLUMN stock REAL DEFAULT 0") - print("Successfully added 'stock' column.") + # conn.execute("ALTER TABLE products ADD COLUMN stock REAL DEFAULT 0") + # print("Successfully added 'stock' column.") - # App.py also expects unit_type, adding it to prevent future headaches - conn.execute("ALTER TABLE products ADD COLUMN unit_type TEXT DEFAULT 'unit'") - print("Successfully added 'unit_type' column.") + # # App.py also expects unit_type, adding it to prevent future headaches + # conn.execute("ALTER TABLE products ADD COLUMN unit_type TEXT DEFAULT 'unit'") + # print("Successfully added 'unit_type' column.") conn.execute("ALTER TABLE dicom ADD COLUMN image_url TEXT;") print("Successfully added 'image_url' column.") diff --git a/templates/macros/modals.html b/templates/macros/modals.html index f024510..c13eb46 100644 --- a/templates/macros/modals.html +++ b/templates/macros/modals.html @@ -49,14 +49,39 @@