63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
from django.db import models
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
class Template(models.Model):
|
|
"""模板模型"""
|
|
MISSION_CHOICES = [
|
|
('all', '全部'),
|
|
('initial_contact', '初步建联'),
|
|
('negotiation', '砍价邮件'),
|
|
('script', '脚本邮件'),
|
|
('follow_up', '合作追踪'),
|
|
]
|
|
|
|
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)
|
|
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)
|