Files
social-media-automation/app/models/tip_template.py
Consultoría AS 049d2133f9 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>
2026-01-28 01:11:44 +00:00

78 lines
2.7 KiB
Python

"""
Modelo de TipTemplate - Banco de tips para generar contenido automático.
"""
from datetime import datetime
from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime
from sqlalchemy.dialects.postgresql import ARRAY
from app.core.database import Base
class TipTemplate(Base):
"""Modelo para templates de tips tech."""
__tablename__ = "tip_templates"
id = Column(Integer, primary_key=True, index=True)
# Categoría del tip
category = Column(String(100), nullable=False, index=True)
# Categorías: hardware, software, seguridad, productividad, ia, redes, etc.
subcategory = Column(String(100), nullable=True)
# Contenido del tip
title = Column(String(255), nullable=False) # Título corto
template = Column(Text, nullable=False) # Template con variables
# Variables que se pueden reemplazar
# Ejemplo: ["sistema_operativo", "herramienta", "beneficio"]
variables = Column(ARRAY(String), nullable=True)
# Variaciones del tip (diferentes formas de decirlo)
variations = Column(ARRAY(String), nullable=True)
# Metadatos
difficulty = Column(String(50), nullable=True) # basico, intermedio, avanzado
target_audience = Column(String(100), nullable=True) # empresas, desarrolladores, general
# Control de uso
used_count = Column(Integer, default=0)
last_used = Column(DateTime, nullable=True)
# Plataformas recomendadas
recommended_platforms = Column(ARRAY(String), nullable=True)
# Ejemplo: ["x", "threads", "instagram"]
# Estado
is_active = Column(Boolean, default=True)
is_evergreen = Column(Boolean, default=True) # ¿Siempre relevante?
# Timestamps
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
def __repr__(self):
return f"<TipTemplate {self.title}>"
def to_dict(self):
"""Convertir a diccionario."""
return {
"id": self.id,
"category": self.category,
"subcategory": self.subcategory,
"title": self.title,
"template": self.template,
"variables": self.variables,
"variations": self.variations,
"difficulty": self.difficulty,
"target_audience": self.target_audience,
"used_count": self.used_count,
"last_used": self.last_used.isoformat() if self.last_used else None,
"recommended_platforms": self.recommended_platforms,
"is_active": self.is_active,
"is_evergreen": self.is_evergreen,
"created_at": self.created_at.isoformat() if self.created_at else None
}