71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
创建初始更新日志测试数据的脚本
|
|
使用方法: python manage.py shell < app/management/commands/seed_changelogs.py
|
|
或: python manage.py shell -c "exec(open('app/management/commands/seed_changelogs.py').read())"
|
|
"""
|
|
from django.utils import timezone
|
|
from datetime import timedelta
|
|
from app.models import Changelog
|
|
|
|
# 删除现有数据
|
|
Changelog.objects.all().delete()
|
|
|
|
# 创建3条测试数据
|
|
changelogs = [
|
|
{
|
|
'version': 'v1.2.0',
|
|
'title': '新增AI智能助手功能',
|
|
'description': '''本次更新为大家带来了全新的AI智能助手功能!
|
|
|
|
主要更新内容:
|
|
1. 集成GPT-4智能问答助手,随时解答你的问题
|
|
2. 支持文章内容智能总结,一键生成摘要
|
|
3. 新增代码片段解释功能,编程更轻松
|
|
4. 优化响应速度,提升用户体验
|
|
|
|
我们一直在努力改进,希望能为用户提供更好的服务。''',
|
|
'update_type': 'new_feature',
|
|
'published_at': timezone.now(),
|
|
'is_published': True,
|
|
},
|
|
{
|
|
'version': 'v1.1.5',
|
|
'title': '性能优化与界面改进',
|
|
'description': '''本次更新主要针对性能优化和界面细节改进。
|
|
|
|
更新内容:
|
|
1. 优化页面加载速度,整体提升30%
|
|
2. 改进搜索算法,搜索结果更准确
|
|
3. 优化移动端适配,界面更美观
|
|
4. 修复若虹用户反馈的若干小问题
|
|
|
|
感谢大家的持续支持!''',
|
|
'update_type': 'improvement',
|
|
'published_at': timezone.now() - timedelta(days=7),
|
|
'is_published': True,
|
|
},
|
|
{
|
|
'version': 'v1.1.4',
|
|
'title': '修复已知问题',
|
|
'description': '''本次更新修复了以下问题:
|
|
|
|
1. 修复了用户在登录时偶发的验证码不显示问题
|
|
2. 修复了文章收藏后刷新页面数据丢失的问题
|
|
3. 修复了移动端导航栏显示异常的问题
|
|
4. 修复了部分浏览器下文件上传失败的问题
|
|
|
|
如遇到其他问题,请通过反馈入口告诉我们。''',
|
|
'update_type': 'bug_fix',
|
|
'published_at': timezone.now() - timedelta(days=14),
|
|
'is_published': True,
|
|
},
|
|
]
|
|
|
|
for data in changelogs:
|
|
Changelog.objects.create(**data)
|
|
|
|
print(f'成功创建 {len(changelogs)} 条更新日志测试数据')
|
|
for cl in Changelog.objects.all().order_by('-published_at'):
|
|
print(f" - {cl.version}: {cl.title} ({cl.get_update_type_display()})")
|