feat: Add Dockerfile and initial Docker setup files

This commit is contained in:
komkida91
2026-01-31 16:04:55 +01:00
parent 70c533e755
commit 59812e547e
31 changed files with 7720 additions and 1776 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -9,6 +9,19 @@ from utils.auth_decorators import login_required
customizer_bp = Blueprint('customizer', __name__)
@customizer_bp.route('/customizer')
def customizer_demo():
"""Ruta de conveniencia: si se pasa ?site_id=ID delega a customizer_view, si no muestra demo"""
sid = request.args.get('site_id')
if sid:
try:
return customizer_view(int(sid))
except Exception:
pass
# Render demo template with empty content
return render_template('customizer.html', site_id='demo', slug='demo', theme=None, content={}, theme_template=None, theme_config={}, available_themes={}, user_plan='base')
@customizer_bp.route('/api/themes')
def list_themes():
"""Listar todos los templates disponibles filtrados por plan"""
@@ -35,12 +48,13 @@ def customizer_view(site_id):
c = conn.cursor()
c.execute('SELECT user_id, slug, theme, content_json FROM sites WHERE id = ?', (site_id,))
site = c.fetchone()
conn.close()
if not site:
conn.close()
return "Sitio no encontrado", 404
if 'user_id' in session and site[0] != session['user_id']:
conn.close()
return "No autorizado", 403
content = json.loads(site[3]) if site[3] else {}
@@ -55,9 +69,10 @@ def customizer_view(site_id):
theme_config = get_theme_config(theme)
# Obtener plan del usuario para filtrar templates
c = conn.cursor()
c.execute('SELECT plan, rubro FROM users WHERE id = ?', (site[0],))
user_data = c.fetchone()
conn.close()
user_plan = user_data[0] if user_data else 'base'
user_rubro = user_data[1] if user_data else 'restaurante'
@@ -91,6 +106,43 @@ def save_customizer():
conn.close()
return jsonify({'success': True})
@customizer_bp.route('/api/customizer/get-blocks/<int:site_id>', methods=['GET'])
def get_blocks(site_id):
"""Retorna los bloques de un sitio"""
conn = sqlite3.connect(MAIN_DB)
c = conn.cursor()
c.execute('SELECT content_json FROM sites WHERE id = ?', (site_id,))
result = c.fetchone()
conn.close()
if not result or not result[0]:
return jsonify([])
try:
content = json.loads(result[0])
return jsonify(content.get('blocks', []))
except:
return jsonify([])
@customizer_bp.route('/api/customizer/get-content/<int:site_id>', methods=['GET'])
def get_content(site_id):
"""Retorna el contenido completo (blocks + settings) de un sitio"""
conn = sqlite3.connect(MAIN_DB)
c = conn.cursor()
c.execute('SELECT content_json FROM sites WHERE id = ?', (site_id,))
result = c.fetchone()
conn.close()
if not result or not result[0]:
return jsonify({'success': True, 'content': {}})
try:
content = json.loads(result[0])
return jsonify({'success': True, 'content': content})
except Exception:
return jsonify({'success': True, 'content': {}})
@customizer_bp.route('/api/customizer/add-block', methods=['POST'])
def add_block():
data = request.get_json()
@@ -102,6 +154,10 @@ def add_block():
c.execute('SELECT content_json FROM sites WHERE id = ?', (site_id,))
result = c.fetchone()
if not result:
conn.close()
return jsonify({'success': False, 'error': 'Sitio no encontrado'}), 404
content = json.loads(result[0]) if result[0] else {}
if 'blocks' not in content: content['blocks'] = []

View File

@@ -0,0 +1,25 @@
from flask import Blueprint, request, jsonify
import json
customizer_bp = Blueprint('customizer_api', __name__)
@customizer_bp.route('/api/customizer/get-blocks/<int:site_id>', methods=['GET'])
def get_blocks(site_id):
"""Retorna los bloques de un sitio"""
import sqlite3
from config import MAIN_DB
conn = sqlite3.connect(MAIN_DB)
c = conn.cursor()
c.execute('SELECT content_json FROM sites WHERE id = ?', (site_id,))
result = c.fetchone()
conn.close()
if not result or not result[0]:
return jsonify([])
try:
content = json.loads(result[0])
return jsonify(content.get('blocks', []))
except:
return jsonify([])