| 12345678910111213141516171819202122232425262728293031323334353637 |
- from django.db import models
- class AttributeMaster(models.Model):
- name = models.CharField(max_length=100, unique=True) # e.g., "Brand", "Capacity"
- is_mandatory = models.BooleanField(default=False)
- def __str__(self):
- return self.name
- class TitleMapping(models.Model):
- product_type = models.CharField(max_length=255, unique=True) # e.g., "Flammable Safety Cabinet-Links"
- # Store sequence as a comma-separated string: "Brand,Product Type,Door Type,Capacity,Dimensions,Color"
- format_sequence = models.TextField()
- def get_sequence_list(self):
- return [item.strip() for item in self.format_sequence.split(',') if item.strip()]
- def __str__(self):
- return self.product_type
-
- class ProcessingTask(models.Model):
- task_id = models.CharField(max_length=100, unique=True)
- original_filename = models.CharField(max_length=255, null=True, blank=True) # New field
- status = models.CharField(max_length=20, default='PENDING')
- download_url = models.TextField(null=True, blank=True)
- created_at = models.DateTimeField(auto_now_add=True)
- completed_at = models.DateTimeField(null=True, blank=True)
- def __str__(self):
- return f"{self.original_filename} - {self.status}"
- @property
- def duration(self):
- """Calculates how long the process took."""
- if self.completed_at and self.created_at:
- return self.completed_at - self.created_at
- return None
|