All checks were successful
Build and Push Docker Image / build (push) Successful in 4m14s
Reference numbers (unified scheme PREFIX-YYYYMM-HOSP-NNNN, e.g. CMP-202606-HHN-0001): - new ReferenceSequence model + generate_reference() helper (apps/core) - Complaint/Inquiry/Observation/Appreciation/Suggestion emit unified refs via save() - prefix-based auto-routing in public track API (CMP/INQ/OBS trackable; APR/SGT internal-only) - removed legacy CMP-/INQ- generators in ui_views, integrations, px_sources - migrations: core.0003_referencesequence, appreciation.0006, feedback.0008, observations.0012 - unit tests (format, sanitization, monthly reset, 40-thread concurrency) QA audit: - isolated E2E hospital sandbox mirroring HH-N + 10 role users (create_e2e_isolated_env) - feedback-modules-audit.spec.ts + audit helper (headed, run-to-completion) - reports/feedback-modules-qa-report.md Also bundles accumulated in-progress work across complaints, observations, organizations, templates, and other modules.
64 lines
2.2 KiB
Python
64 lines
2.2 KiB
Python
from django.db import migrations
|
|
from django.utils import timezone
|
|
|
|
|
|
def backfill_sent_to_department(apps, schema_editor):
|
|
Complaint = apps.get_model("complaints", "Complaint")
|
|
Inquiry = apps.get_model("complaints", "Inquiry")
|
|
CID = apps.get_model("complaints", "ComplaintInvolvedDepartment")
|
|
|
|
Complaint.objects.filter(department__isnull=False).update(sent_to_department=True)
|
|
Complaint.objects.filter(
|
|
sent_to_department=True,
|
|
sent_to_department_at__isnull=True,
|
|
forwarded_to_dept_at__isnull=False,
|
|
).update(sent_to_department_at=models.F("forwarded_to_dept_at"))
|
|
Complaint.objects.filter(
|
|
sent_to_department=True, sent_to_department_at__isnull=True
|
|
).update(sent_to_department_at=timezone.now())
|
|
|
|
Inquiry.objects.filter(department__isnull=False).update(sent_to_department=True)
|
|
Inquiry.objects.filter(
|
|
sent_to_department=True,
|
|
sent_to_department_at__isnull=True,
|
|
transferred_at__isnull=False,
|
|
).update(sent_to_department_at=models.F("transferred_at"))
|
|
Inquiry.objects.filter(
|
|
sent_to_department=True, sent_to_department_at__isnull=True
|
|
).update(sent_to_department_at=timezone.now())
|
|
|
|
CID.objects.filter(forwarded_at__isnull=False).update(sent=True)
|
|
CID.objects.filter(sent=True, sent_at__isnull=True).update(
|
|
sent_at=models.F("forwarded_at")
|
|
)
|
|
CID.objects.filter(sent=True, sent_at__isnull=True).update(
|
|
sent_at=timezone.now()
|
|
)
|
|
|
|
|
|
def reverse_backfill(apps, schema_editor):
|
|
Complaint = apps.get_model("complaints", "Complaint")
|
|
Inquiry = apps.get_model("complaints", "Inquiry")
|
|
CID = apps.get_model("complaints", "ComplaintInvolvedDepartment")
|
|
|
|
Complaint.objects.all().update(
|
|
sent_to_department=False, sent_to_department_at=None
|
|
)
|
|
Inquiry.objects.all().update(
|
|
sent_to_department=False, sent_to_department_at=None
|
|
)
|
|
CID.objects.all().update(sent=False, sent_at=None)
|
|
|
|
|
|
from django.db import models
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("complaints", "0005_add_sent_to_department_fields"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(backfill_sent_to_department, reverse_backfill),
|
|
]
|