73 lines
3.0 KiB
Python
73 lines
3.0 KiB
Python
"""第7段抓图用的本地 sqlite 种子:一个团队 + 两个商品 + 一个带脚本的项目。
|
|
只在 DB_ENGINE=sqlite 的本地库跑,不碰共享开发库。
|
|
"""
|
|
|
|
import django
|
|
import os
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airshelf.settings.development")
|
|
os.environ.setdefault("DB_ENGINE", "sqlite")
|
|
django.setup()
|
|
|
|
from apps.accounts.models import Team, TeamMember, User # noqa: E402
|
|
from apps.billing.models import CreditAccount # noqa: E402
|
|
from apps.products.models import Product # noqa: E402
|
|
from apps.projects.models import Project, ProjectStage, ScriptSegment, ScriptVersion # noqa: E402
|
|
from apps.projects.services.pipeline import STAGE_ORDER # noqa: E402
|
|
|
|
user, created = User.objects.get_or_create(username="seg7", defaults={"is_active": True})
|
|
user.set_password("Restraint2026")
|
|
user.save()
|
|
team, _ = Team.objects.get_or_create(name="Seg7 Team", defaults={"owner": user})
|
|
TeamMember.objects.get_or_create(team=team, user=user, defaults={"role": TeamMember.Role.OWNER, "status": "active"})
|
|
CreditAccount.objects.get_or_create(team=team, defaults={"balance": "9999.0000"})
|
|
|
|
old, _ = Product.objects.get_or_create(
|
|
team=team, title="夜光面膜", defaults={"created_by": user, "category": "美妆护肤", "target_audience": "熬夜上班族"}
|
|
)
|
|
new, _ = Product.objects.get_or_create(
|
|
team=team, title="鎏金精华水", defaults={"created_by": user, "category": "美妆护肤", "target_audience": "都市白领"}
|
|
)
|
|
|
|
project, _ = Project.objects.get_or_create(
|
|
team=team,
|
|
name="夜光面膜 · 短视频 · v1",
|
|
defaults={
|
|
"created_by": user,
|
|
"product": old,
|
|
"metadata": {"wizard": {"persona": "urban", "presentation_format": "oral", "video_structure": "pain", "total_duration": 30}},
|
|
},
|
|
)
|
|
for stage in STAGE_ORDER:
|
|
ProjectStage.objects.get_or_create(project=project, stage=stage)
|
|
|
|
script, made = ScriptVersion.objects.get_or_create(
|
|
project=project,
|
|
title="熬夜脸急救",
|
|
defaults={
|
|
"content": "{}",
|
|
"source": "ai",
|
|
"is_adopted": True,
|
|
"metadata": {"presentation_format": "oral", "video_structure": "pain", "total_duration": 30, "hook": "熬夜脸还有救吗"},
|
|
},
|
|
)
|
|
if made:
|
|
for order, duration, role, exposure, narration in [
|
|
(0, 5, "钩子", "未出现", "连着熬三天,这张脸还有救吗?"),
|
|
(1, 8, "痛点", "背景陈列", "早上照镜子,毛孔粗、脸发黄,粉底都盖不住。"),
|
|
(2, 12, "卖点", "手持展示", "这盒夜光面膜敷 10 分钟,精华浓度是普通款的三倍。"),
|
|
(3, 5, "CTA", "特写", "家里常煮茶的,这盒真省事,今晚买二送一。"),
|
|
]:
|
|
ScriptSegment.objects.create(
|
|
script_version=script,
|
|
sort_order=order,
|
|
duration_seconds=duration,
|
|
role=role,
|
|
product_exposure=exposure,
|
|
narration=narration,
|
|
visual_prompt=f"{role}镜:{narration}",
|
|
)
|
|
|
|
print("project", project.id)
|
|
print("old_product", old.id, "new_product", new.id)
|