feat: add category-driven ticket workflows
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
STANDARD_CATEGORIES = [
|
||||
("business_issue", "业务问题", "业务进度、业务规则、业务状态确认等支持请求。", 10),
|
||||
("technical_issue", "技术问题", "系统异常、接口故障、服务不可用等技术排查请求。", 20),
|
||||
("data_issue", "数据问题", "数据缺失、数据不一致、采集或同步结果异常。", 30),
|
||||
("operation_issue", "操作问题", "用户操作指导、配置入口、权限使用等支持请求。", 40),
|
||||
]
|
||||
|
||||
|
||||
def seed_standard_categories(apps, schema_editor):
|
||||
TicketCategory = apps.get_model("tickets", "TicketCategory")
|
||||
for code, name, description, sort_order in STANDARD_CATEGORIES:
|
||||
TicketCategory.objects.update_or_create(
|
||||
code=code,
|
||||
defaults={
|
||||
"name": name,
|
||||
"description": description,
|
||||
"enabled": True,
|
||||
"sort_order": sort_order,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def remove_standard_categories(apps, schema_editor):
|
||||
TicketCategory = apps.get_model("tickets", "TicketCategory")
|
||||
category_codes = [category[0] for category in STANDARD_CATEGORIES]
|
||||
TicketCategory.objects.filter(code__in=category_codes).delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("tickets", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="ticket",
|
||||
name="ai_solution",
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ticket",
|
||||
name="is_resolved",
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ticket",
|
||||
name="problem_object",
|
||||
field=models.CharField(blank=True, max_length=160),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ticket",
|
||||
name="problem_performance",
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ticket",
|
||||
name="replied_to_customer",
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ticket",
|
||||
name="resolution_summary",
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ticket",
|
||||
name="submitter_name",
|
||||
field=models.CharField(blank=True, max_length=80),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="ticket",
|
||||
name="submitter_org",
|
||||
field=models.CharField(blank=True, max_length=160),
|
||||
),
|
||||
migrations.RunPython(seed_standard_categories, remove_standard_categories),
|
||||
]
|
||||
Reference in New Issue
Block a user