ixg_platform/apps/qc/models.py

27 lines
1.1 KiB
Python

import uuid
from django.db import models
class QCResult(models.Model):
class VisualGrade(models.TextChoices):
A = "A", "A"
B = "B", "B"
C = "C", "C"
FAIL = "Fail", "Fail"
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
batch = models.ForeignKey("batches.ProcessingBatch", on_delete=models.CASCADE, related_name="qc_results")
ffa_percentage = models.DecimalField(max_digits=5, decimal_places=2)
moisture_percentage = models.DecimalField(max_digits=5, decimal_places=2)
peroxide_value = models.DecimalField(max_digits=5, decimal_places=2)
visual_grade = models.CharField(max_length=5, choices=VisualGrade.choices)
overall_pass = models.BooleanField()
tested_by = models.CharField(max_length=255, blank=True)
tested_at = models.DateTimeField(auto_now_add=True)
lab_reference = models.CharField(max_length=255, blank=True)
class Meta:
db_table = "qc_results"
def __str__(self):
return f"QC for {self.batch.batch_reference}: {PASS if self.overall_pass else FAIL}"