Files
fonrey/apps/client/models/contacts.py
ishenwei 79c3cf2924 feat(models): add Chinese verbose_name to all 74 models (Phase 4.0)
为所有 Django 模型添加 Meta.verbose_name 和 verbose_name_plural(中文表名),
覆盖 10 个 app 的全部 74 个业务模型。

Phase 4.0 范围:
- 仅 Meta 类级别中文名(用于 Django Admin、drf-spectacular OpenAPI title、错误信息)
- 字段级 verbose_name= 和 help_text= 留待 Phase 4.1(待 PM 补全 DATA_MODEL 后同步)

变更:
- 20 个 models 文件改动(每个模型 +2 行)
- 8 个 0002/0003 迁移文件(Meta options 变更)
- apps/tenant/migrations/0001_initial.py(之前漏生成的 tenant 模型迁移)

manage.py check: 0 issues。
2026-04-29 19:10:38 +08:00

150 lines
5.2 KiB
Python

from django.contrib.postgres.fields import ArrayField
from django.db import models
from core.enums import (
ClientBuildingAgeRange,
ClientContactGender,
ClientDecoration,
ClientFloorPreference,
ClientOrientation,
ClientRequirementType,
)
from core.models.base import UUIDPrimaryKeyModel
class ClientContact(UUIDPrimaryKeyModel):
client = models.ForeignKey(
"fonrey_client.Client", on_delete=models.CASCADE, related_name="contacts"
)
sort_order = models.SmallIntegerField(default=0)
name = models.CharField(max_length=50)
gender = models.CharField(
max_length=10, choices=ClientContactGender.choices, default=ClientContactGender.MALE
)
phone_enc = models.BinaryField()
phone_hash = models.CharField(max_length=64)
phone_country_code = models.CharField(max_length=10, default="+86")
phone_is_invalid = models.BooleanField(default=False)
phone2_enc = models.BinaryField(null=True, blank=True)
phone2_hash = models.CharField(max_length=64, blank=True, default="")
wechat = models.CharField(max_length=100, blank=True, default="")
qq = models.CharField(max_length=20, blank=True, default="")
remarks = models.CharField(max_length=200, blank=True, default="")
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
deleted_at = models.DateTimeField(null=True, blank=True)
created_by = models.ForeignKey(
"org.Staff",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="created_client_contacts",
)
class Meta:
db_table = "client_contacts"
verbose_name = "客源联系人"
verbose_name_plural = "客源联系人"
indexes = [
models.Index(fields=["phone_hash"], name="idx_cc_phone_hash"),
models.Index(fields=["phone2_hash"], name="idx_cc_phone2_hash"),
models.Index(fields=["client"], name="idx_cc_client"),
]
class ClientRequirement(UUIDPrimaryKeyModel):
client = models.ForeignKey(
"fonrey_client.Client", on_delete=models.CASCADE, related_name="requirements"
)
requirement_type = models.CharField(
max_length=20, choices=ClientRequirementType.choices
)
is_primary = models.BooleanField(default=True)
budget_min = models.DecimalField(
max_digits=12, decimal_places=2, null=True, blank=True
)
budget_max = models.DecimalField(
max_digits=12, decimal_places=2, null=True, blank=True
)
area_min = models.DecimalField(
max_digits=8, decimal_places=2, null=True, blank=True
)
area_max = models.DecimalField(
max_digits=8, decimal_places=2, null=True, blank=True
)
bedroom_counts = ArrayField(
models.SmallIntegerField(), blank=True, default=list
)
floor_preferences = ArrayField(
models.CharField(max_length=20, choices=ClientFloorPreference.choices),
blank=True,
default=list,
)
orientations = ArrayField(
models.CharField(max_length=10, choices=ClientOrientation.choices),
blank=True,
default=list,
)
decorations = ArrayField(
models.CharField(max_length=10, choices=ClientDecoration.choices),
blank=True,
default=list,
)
building_age_ranges = ArrayField(
models.CharField(max_length=20, choices=ClientBuildingAgeRange.choices),
blank=True,
default=list,
)
intent_district_ids = ArrayField(
models.UUIDField(), blank=True, default=list
)
intent_business_area_ids = ArrayField(
models.UUIDField(), blank=True, default=list
)
intent_complex_names = models.TextField(blank=True, default="")
transportation = models.CharField(max_length=50, blank=True, default="")
intent_school_names = models.TextField(blank=True, default="")
school_enrollment_date = models.DateField(null=True, blank=True)
traffic_preference = models.TextField(blank=True, default="")
requirement_notes = models.CharField(max_length=200, blank=True, default="")
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "client_requirements"
verbose_name = "客源需求"
verbose_name_plural = "客源需求"
indexes = [
models.Index(fields=["client"], name="idx_creq_client"),
models.Index(fields=["requirement_type", "client"], name="idx_creq_type"),
models.Index(fields=["budget_min", "budget_max"], name="idx_creq_budget"),
models.Index(fields=["area_min", "area_max"], name="idx_creq_area"),
]
class ClientSchoolPreference(UUIDPrimaryKeyModel):
requirement = models.ForeignKey(
ClientRequirement,
on_delete=models.CASCADE,
related_name="school_preferences",
)
school_id = models.UUIDField(null=True, blank=True)
school_name = models.CharField(max_length=100)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = "client_school_preferences"
verbose_name = "意向学校"
verbose_name_plural = "意向学校"
indexes = [
models.Index(fields=["requirement"], name="idx_csp_requirement"),
]