Download apps/documents/models/placeholder.py from jun2024/fc: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/documents/models/placeholder.py
- Command line
-
hf download hf://spaces/jun2024/fc/apps/documents/models/placeholder.py
-
curl -L -o placeholder.py https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/documents/models/placeholder.py
1.85 kB
| """ | |
| 法律文书生成系统 - 占位符模型 | |
| 本模块定义占位符(替换词)相关的数据模型. | |
| """ | |
| from __future__ import annotations | |
| from typing import ClassVar | |
| from django.db import models | |
| from django.utils.translation import gettext_lazy as _ | |
| class Placeholder(models.Model): | |
| """ | |
| 替换词 | |
| 定义文书模板中的占位符,用于统一管理占位符定义. | |
| 具体的数据替换和格式化由外部脚本实现. | |
| Requirements: 3.1, 3.4, 7.3 | |
| """ | |
| id: int | |
| key = models.CharField( | |
| max_length=100, unique=True, verbose_name=_("占位符键"), help_text=_("模板中使用的占位符名称,如 case_name") | |
| ) | |
| display_name = models.CharField(max_length=200, verbose_name=_("显示名称"), help_text=_("用于界面显示的友好名称")) | |
| example_value = models.CharField( | |
| max_length=200, blank=True, verbose_name=_("示例值"), help_text=_("占位符的示例值,用于说明用途") | |
| ) | |
| description = models.TextField(blank=True, verbose_name=_("说明")) | |
| is_active = models.BooleanField(default=True, verbose_name=_("是否启用")) | |
| class Meta: | |
| app_label = "documents" | |
| verbose_name = _("替换词") | |
| verbose_name_plural = _("替换词") | |
| ordering: ClassVar = ["key"] | |
| indexes: ClassVar = [ | |
| models.Index(fields=["is_active"]), | |
| ] | |
| def __str__(self) -> str: | |
| return f"{self.display_name} ({self.key})" | |
| def data_path(self) -> str: | |
| return getattr(self, "_data_path", "") | |
| def data_path(self, value: str) -> None: | |
| self._data_path = value | |
| def category(self) -> str: | |
| return getattr(self, "_category", "") | |
| def category(self, value: str) -> None: | |
| self._category = value | |