from django.db import models from django.contrib.auth import get_user_model class ReportDocument(models.Model): STATUS_CHOICES = [ ('pending', 'Pendiente'), ('processing', 'Procesando'), ('ready', 'Listo'), ('error', 'Error'), ] TYPE_REPORT = [ ('cumplimiento', 'cumplimiento'), ('control_pedimento', 'control_pedimento'), ] user = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, related_name='report_documents') filters = models.JSONField(blank=True, null=True) status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='pending') file = models.FileField(upload_to='reports/', blank=True, null=True) report_type = models.CharField(max_length=30, choices=TYPE_REPORT, default='cumplimiento') error_message = models.TextField(blank=True, null=True) created_at = models.DateTimeField(auto_now_add=True) finished_at = models.DateTimeField(blank=True, null=True) def __str__(self): return f"Reporte {self.id} - {self.status}"