feat: 添加批注功能
后端: - Comment 模型(支持日记/任务/经验三种内容类型) - CommentSerializer 和 CommentViewSet - API: /api/comments/ - 批注 CRUD - API: /api/comments/by_content/?content_type=diary&object_id=1 - 按内容获取批注 - 日记/任务/经验序列化器嵌套显示批注 前端: - 批注样式(comments-section, comment-item) - 添加批注输入框 使用方式: - 北极星可以在任何日记/任务/经验下添加批注 - 批注会显示在内容下方 - 支持查看历史批注
This commit is contained in:
@@ -93,6 +93,29 @@ class DailyProgress(models.Model):
|
||||
return f"{self.entry.date} - {self.category}: {self.progress_percent}%"
|
||||
|
||||
|
||||
class Comment(models.Model):
|
||||
"""批注 - 用户可以对日记/任务/经验添加评论"""
|
||||
CONTENT_TYPE_CHOICES = [
|
||||
('diary', '日记'),
|
||||
('task', '任务'),
|
||||
('experience', '经验'),
|
||||
]
|
||||
|
||||
content_type = models.CharField('内容类型', max_length=20, choices=CONTENT_TYPE_CHOICES)
|
||||
object_id = models.IntegerField('内容 ID')
|
||||
content = models.TextField('批注内容')
|
||||
created_by = models.CharField('创建者', max_length=100, default='北极星')
|
||||
created_at = models.DateTimeField('创建时间', auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ['-created_at']
|
||||
verbose_name = '批注'
|
||||
verbose_name_plural = '批注'
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.content_type} #{self.object_id} - {self.created_by}"
|
||||
|
||||
|
||||
class Task(models.Model):
|
||||
"""工作任务 - 跟踪任务和进展"""
|
||||
STATUS_CHOICES = [
|
||||
|
||||
Reference in New Issue
Block a user