78 lines
3.0 KiB
Python
78 lines
3.0 KiB
Python
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
class TemplateCategory(models.Model):
|
|
"""模板分类模型"""
|
|
name = models.CharField(_('分类名称'), max_length=100)
|
|
description = models.TextField(_('分类描述'), blank=True, null=True)
|
|
created_at = models.DateTimeField(_('创建时间'), auto_now_add=True)
|
|
updated_at = models.DateTimeField(_('更新时间'), auto_now=True)
|
|
|
|
class Meta:
|
|
verbose_name = _('模板分类')
|
|
verbose_name_plural = _('模板分类')
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class Template(models.Model):
|
|
"""模板模型"""
|
|
MISSION_CHOICES = [
|
|
('initial_contact', '初步联系'),
|
|
('follow_up', '跟进'),
|
|
('negotiation', '谈判'),
|
|
('closing', '成交'),
|
|
('other', '其他'),
|
|
]
|
|
|
|
PLATFORM_CHOICES = [
|
|
('tiktok', 'TikTok'),
|
|
('instagram', 'Instagram'),
|
|
('youtube', 'YouTube'),
|
|
('facebook', 'Facebook'),
|
|
('twitter', 'Twitter'),
|
|
('other', '其他'),
|
|
]
|
|
|
|
COLLABORATION_CHOICES = [
|
|
('paid_promotion', '付费推广'),
|
|
('affiliate', '联盟营销'),
|
|
('sponsored_content', '赞助内容'),
|
|
('brand_ambassador', '品牌大使'),
|
|
('other', '其他'),
|
|
]
|
|
|
|
SERVICE_CHOICES = [
|
|
('voice', '声优 - 交谈'),
|
|
('text', '文本'),
|
|
('video', '视频'),
|
|
('image', '图片'),
|
|
('other', '其他'),
|
|
]
|
|
|
|
title = models.CharField(_('模板标题'), max_length=200)
|
|
content = models.TextField(_('模板内容'))
|
|
preview = models.TextField(_('内容预览'), blank=True, null=True)
|
|
category = models.ForeignKey(TemplateCategory, on_delete=models.CASCADE, related_name='templates', verbose_name=_('模板分类'))
|
|
mission = models.CharField(_('任务类型'), max_length=50, choices=MISSION_CHOICES, default='initial_contact')
|
|
platform = models.CharField(_('平台'), max_length=50, choices=PLATFORM_CHOICES, default='tiktok')
|
|
collaboration_type = models.CharField(_('合作模式'), max_length=50, choices=COLLABORATION_CHOICES, default='paid_promotion')
|
|
service = models.CharField(_('服务类型'), max_length=50, choices=SERVICE_CHOICES, default='text')
|
|
is_public = models.BooleanField(_('是否公开'), default=True)
|
|
created_at = models.DateTimeField(_('创建时间'), auto_now_add=True)
|
|
updated_at = models.DateTimeField(_('更新时间'), auto_now=True)
|
|
|
|
class Meta:
|
|
verbose_name = _('模板')
|
|
verbose_name_plural = _('模板')
|
|
|
|
def __str__(self):
|
|
return self.title
|
|
|
|
def save(self, *args, **kwargs):
|
|
# 自动生成内容预览
|
|
if self.content and not self.preview:
|
|
# 截取前100个字符作为预览
|
|
self.preview = self.content[:100] + ('...' if len(self.content) > 100 else '')
|
|
super().save(*args, **kwargs)
|