- Versioned product specification table (Unrefined Shea Butter v1.0 seed) with spec-based QC evaluation replacing hard-coded thresholds - Structured QC results with test methods and four-eyes verification (submitter cannot self-approve) - reportlab IXG Quality Summary PDF auto-generated on quality approval, SHA-256 hashed; original independent lab PDF kept authoritative - CertificateOfAnalysis version/status/hash/approval/supersede lifecycle; commercial release publishes to buyers and triggers notification - EUDR evidence workflow: Facility, OriginZone, CollectorGroup, HarvestIntake, IntakeBatchLineage, DueDiligenceCase, EUDREvidence, RiskAssessment, MitigationAction, DueDiligenceStatementReference with rule-based completeness check and risk assessment (no AI legal conclusions) - Ops portal: QC Approvals, CoA Reviews, EUDR Compliance screens - Buyer portal: /portal/compliance page - 22 automated tests covering four-eyes, CAPA, PDF+hash, publish/notify, EUDR blocks and buyer isolation
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
from django.db import migrations
|
|
|
|
|
|
def seed_default_spec(apps, schema_editor):
|
|
ProductSpecification = apps.get_model("compliance", "ProductSpecification")
|
|
SpecParameter = apps.get_model("compliance", "SpecParameter")
|
|
|
|
spec, created = ProductSpecification.objects.get_or_create(
|
|
product="Unrefined Shea Butter",
|
|
version="1.0",
|
|
defaults={
|
|
"status": "approved",
|
|
"is_current": True,
|
|
},
|
|
)
|
|
if created:
|
|
parameters = [
|
|
("ffa", "%", None, "3.000", "", 1),
|
|
("moisture", "%", None, "0.100", "", 2),
|
|
("peroxide", "meq O2/kg", None, "10.000", "", 3),
|
|
("visual", "grade", None, None, "A,B,C", 4),
|
|
]
|
|
for parameter, unit, min_value, max_value, allowed, sort_order in parameters:
|
|
SpecParameter.objects.create(
|
|
spec=spec,
|
|
parameter=parameter,
|
|
unit=unit,
|
|
min_value=min_value,
|
|
max_value=max_value,
|
|
allowed_values=allowed,
|
|
required=True,
|
|
sort_order=sort_order,
|
|
)
|
|
|
|
|
|
def remove_default_spec(apps, schema_editor):
|
|
ProductSpecification = apps.get_model("compliance", "ProductSpecification")
|
|
ProductSpecification.objects.filter(product="Unrefined Shea Butter", version="1.0").delete()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("compliance", "0001_initial"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(seed_default_spec, remove_default_spec),
|
|
]
|