- apps/client (11 models): Client, ClientContact, ClientRequirement, ClientSchoolPreference, ClientFollowLog (partitioned), ClientFollowLogAttachment, ClientViewing, ClientPropertyMatch, ClientStatusLog, ClientFavoriteFolder, ClientFolderItem - apps/client/0002 RunSQL: PARTITION BY RANGE(created_at) for client_follow_logs + monthly partitions + default; triggers update_client_last_follow + update_client_viewing_progress; partial unique index on client_no WHERE deleted_at IS NULL - apps/setting (4 models): LookupGroup, LookupItem, TenantSetting, FieldRequirementRule (tenant schema only per spec) manage.py check green; all 9 Phase 2 apps complete.
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
from django.db import models
|
|
|
|
from core.models.base import UUIDPrimaryKeyModel
|
|
|
|
|
|
class LookupGroup(UUIDPrimaryKeyModel):
|
|
module = models.CharField(max_length=50)
|
|
key = models.CharField(max_length=100)
|
|
label_zh = models.CharField(max_length=50)
|
|
description = models.TextField(blank=True, default="")
|
|
sort_order = models.SmallIntegerField(default=0)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
db_table = "lookup_groups"
|
|
constraints = [
|
|
models.UniqueConstraint(
|
|
fields=["module", "key"], name="uq_lookup_groups_module_key"
|
|
),
|
|
]
|
|
|
|
|
|
class LookupItem(UUIDPrimaryKeyModel):
|
|
group = models.ForeignKey(
|
|
LookupGroup, on_delete=models.CASCADE, related_name="items"
|
|
)
|
|
value = models.CharField(max_length=100)
|
|
label_zh = models.CharField(max_length=50)
|
|
is_system = models.BooleanField(default=False)
|
|
is_active = models.BooleanField(default=True)
|
|
sort_order = models.SmallIntegerField(default=0)
|
|
created_by = models.ForeignKey(
|
|
"org.Staff",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="created_lookup_items",
|
|
)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
db_table = "lookup_items"
|
|
constraints = [
|
|
models.UniqueConstraint(
|
|
fields=["group", "value"], name="uq_lookup_items_group_value"
|
|
),
|
|
]
|
|
indexes = [
|
|
models.Index(
|
|
fields=["group", "is_active", "sort_order"],
|
|
name="idx_lookup_items_active",
|
|
),
|
|
]
|