- 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.
76 lines
2.2 KiB
Python
76 lines
2.2 KiB
Python
from django.db import models
|
|
|
|
from core.enums import (
|
|
FieldRuleEntityType,
|
|
FieldRuleModule,
|
|
FieldRuleRequirement,
|
|
SettingValueType,
|
|
)
|
|
from core.models.base import UUIDPrimaryKeyModel
|
|
|
|
TRADE_STATUS_CHOICES = (
|
|
("sale", "出售"),
|
|
("rent", "出租"),
|
|
("sale_rent", "租售"),
|
|
("*", "全部"),
|
|
)
|
|
|
|
|
|
class TenantSetting(UUIDPrimaryKeyModel):
|
|
category = models.CharField(max_length=50)
|
|
key = models.CharField(max_length=100)
|
|
value = models.JSONField()
|
|
value_type = models.CharField(max_length=20, choices=SettingValueType.choices)
|
|
updated_by = models.ForeignKey(
|
|
"org.Staff",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="updated_tenant_settings",
|
|
)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
db_table = "tenant_settings"
|
|
constraints = [
|
|
models.UniqueConstraint(
|
|
fields=["category", "key"], name="uq_tenant_settings_cat_key"
|
|
),
|
|
]
|
|
indexes = [
|
|
models.Index(fields=["category"], name="idx_tenant_settings_cat"),
|
|
]
|
|
|
|
|
|
class FieldRequirementRule(UUIDPrimaryKeyModel):
|
|
module = models.CharField(max_length=20, choices=FieldRuleModule.choices)
|
|
entity_type = models.CharField(max_length=50, choices=FieldRuleEntityType.choices)
|
|
trade_status = models.CharField(max_length=20, choices=TRADE_STATUS_CHOICES)
|
|
field_key = models.CharField(max_length=50)
|
|
requirement = models.CharField(
|
|
max_length=10, choices=FieldRuleRequirement.choices
|
|
)
|
|
updated_by = models.ForeignKey(
|
|
"org.Staff",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="updated_field_rules",
|
|
)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
db_table = "field_requirement_rules"
|
|
constraints = [
|
|
models.UniqueConstraint(
|
|
fields=["module", "entity_type", "trade_status", "field_key"],
|
|
name="uq_field_req_quad",
|
|
),
|
|
]
|
|
indexes = [
|
|
models.Index(
|
|
fields=["module", "entity_type", "trade_status"],
|
|
name="idx_field_req_lookup",
|
|
),
|
|
]
|