Files
fonrey/apps/setting/models/lookup.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

60 lines
1.9 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"
verbose_name = "查找组"
verbose_name_plural = "查找组"
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"
verbose_name = "查找项"
verbose_name_plural = "查找项"
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",
),
]