Download apps/cases/models/template_binding.py from jun2024/fc: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/cases/models/template_binding.py
- Command line
-
hf download hf://spaces/jun2024/fc/apps/cases/models/template_binding.py
-
curl -L -o template_binding.py https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/cases/models/template_binding.py
1.45 kB
| """Module for template binding.""" | |
| from __future__ import annotations | |
| from typing import ClassVar | |
| from django.db import models | |
| from django.utils.translation import gettext_lazy as _ | |
| class BindingSource(models.TextChoices): | |
| """绑定来源""" | |
| AUTO_RECOMMENDED = "auto_recommended", _("自动推荐") | |
| MANUAL_BOUND = "manual_bound", _("手动绑定") | |
| class CaseTemplateBinding(models.Model): | |
| """案件模板绑定关系""" | |
| id: int | |
| case = models.ForeignKey( | |
| "cases.Case", on_delete=models.CASCADE, related_name="template_bindings", verbose_name=_("案件") | |
| ) | |
| template = models.ForeignKey( | |
| "documents.DocumentTemplate", on_delete=models.CASCADE, related_name="case_bindings", verbose_name=_("文书模板") | |
| ) | |
| binding_source = models.CharField( | |
| max_length=20, choices=BindingSource.choices, default=BindingSource.AUTO_RECOMMENDED, verbose_name=_("绑定来源") | |
| ) | |
| created_at = models.DateTimeField(auto_now_add=True, verbose_name=_("绑定时间")) | |
| class Meta: | |
| verbose_name = _("案件模板绑定") | |
| verbose_name_plural = _("案件模板绑定") | |
| unique_together: ClassVar = ["case", "template"] | |
| indexes: ClassVar = [ | |
| models.Index(fields=["case", "binding_source"]), | |
| models.Index(fields=["template"]), | |
| ] | |
| def __str__(self) -> str: | |
| return f"{self.case_id}-{self.template_id}-{self.binding_source}" | |