Implementación inicial del sistema de automatización de redes sociales
- Estructura completa del proyecto con FastAPI - Modelos de base de datos (productos, servicios, posts, calendario, interacciones) - Publishers para X, Threads, Instagram, Facebook - Generador de contenido con DeepSeek API - Worker de Celery con tareas programadas - Dashboard básico con templates HTML - Docker Compose para despliegue - Documentación completa Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
75
app/models/image_template.py
Normal file
75
app/models/image_template.py
Normal file
@@ -0,0 +1,75 @@
|
||||
"""
|
||||
Modelo de ImageTemplate - Plantillas para generar imágenes.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime, JSON
|
||||
from sqlalchemy.dialects.postgresql import ARRAY
|
||||
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class ImageTemplate(Base):
|
||||
"""Modelo para plantillas de imágenes."""
|
||||
|
||||
__tablename__ = "image_templates"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
|
||||
# Información básica
|
||||
name = Column(String(100), nullable=False, index=True)
|
||||
description = Column(String(255), nullable=True)
|
||||
|
||||
# Categoría
|
||||
category = Column(String(50), nullable=False)
|
||||
# Categorías: tip, producto, servicio, promocion, etc.
|
||||
|
||||
# Archivo de plantilla
|
||||
template_file = Column(String(255), nullable=False) # Ruta al archivo HTML/template
|
||||
|
||||
# Variables que acepta la plantilla
|
||||
variables = Column(ARRAY(String), nullable=False)
|
||||
# Ejemplo: ["titulo", "contenido", "hashtags", "logo"]
|
||||
|
||||
# Configuración de diseño
|
||||
design_config = Column(JSON, nullable=True)
|
||||
# Ejemplo: {
|
||||
# "width": 1080,
|
||||
# "height": 1080,
|
||||
# "background_color": "#1a1a2e",
|
||||
# "accent_color": "#d4a574",
|
||||
# "font_family": "Inter"
|
||||
# }
|
||||
|
||||
# Tamaños de salida
|
||||
output_sizes = Column(JSON, nullable=True)
|
||||
# Ejemplo: {
|
||||
# "instagram": {"width": 1080, "height": 1080},
|
||||
# "x": {"width": 1200, "height": 675},
|
||||
# "facebook": {"width": 1200, "height": 630}
|
||||
# }
|
||||
|
||||
# Estado
|
||||
is_active = Column(Boolean, default=True)
|
||||
|
||||
# Timestamps
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ImageTemplate {self.name}>"
|
||||
|
||||
def to_dict(self):
|
||||
"""Convertir a diccionario."""
|
||||
return {
|
||||
"id": self.id,
|
||||
"name": self.name,
|
||||
"description": self.description,
|
||||
"category": self.category,
|
||||
"template_file": self.template_file,
|
||||
"variables": self.variables,
|
||||
"design_config": self.design_config,
|
||||
"output_sizes": self.output_sizes,
|
||||
"is_active": self.is_active,
|
||||
"created_at": self.created_at.isoformat() if self.created_at else None
|
||||
}
|
||||
Reference in New Issue
Block a user