增加阅读笔记

This commit is contained in:
2026-01-05 23:11:41 +08:00
parent 11ec013070
commit 57a7a30bc8
10 changed files with 28 additions and 2 deletions

1
.gitignore vendored
View File

@@ -7,6 +7,7 @@ env/
db.sqlite3 db.sqlite3
*.db *.db
*.sqlite *.sqlite
*.sqlite3
# 媒体文件 # 媒体文件
media/ media/

View File

@@ -12,12 +12,13 @@ class ReadingRecordForm(forms.ModelForm):
"""阅读记录表单""" """阅读记录表单"""
class Meta: class Meta:
model = ReadingRecord model = ReadingRecord
fields = ['type', 'title', 'source', 'progress', 'file'] fields = ['type', 'title', 'source', 'progress', 'note', 'file']
widgets = { widgets = {
'type': forms.Select(attrs={'class': 'form-select'}), 'type': forms.Select(attrs={'class': 'form-select'}),
'title': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入标题'}), 'title': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入标题'}),
'source': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入来源'}), 'source': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入来源'}),
'progress': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入进度'}), 'progress': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入进度'}),
'note': forms.Textarea(attrs={'class': 'form-control', 'rows': 4, 'placeholder': '请输入阅读笔记'}),
'file': forms.FileInput(attrs={'class': 'form-control'}), 'file': forms.FileInput(attrs={'class': 'form-control'}),
} }

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.1.4 on 2026-01-05 15:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0002_familytasktype_plantype_priority_readingtype_status_and_more'),
]
operations = [
migrations.AddField(
model_name='readingrecord',
name='note',
field=models.TextField(blank=True, null=True, verbose_name='阅读笔记'),
),
]

View File

@@ -78,6 +78,7 @@ class ReadingRecord(models.Model):
title = models.CharField(max_length=200, verbose_name="标题") title = models.CharField(max_length=200, verbose_name="标题")
source = models.CharField(max_length=200, blank=True, null=True, verbose_name="来源") source = models.CharField(max_length=200, blank=True, null=True, verbose_name="来源")
progress = models.CharField(max_length=100, blank=True, null=True, verbose_name="进度") progress = models.CharField(max_length=100, blank=True, null=True, verbose_name="进度")
note = models.TextField(blank=True, null=True, verbose_name="阅读笔记")
file = models.FileField(upload_to='reading_files/', blank=True, null=True, verbose_name="上传文件") file = models.FileField(upload_to='reading_files/', blank=True, null=True, verbose_name="上传文件")
created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
updated_at = models.DateTimeField(auto_now=True, verbose_name="更新时间") updated_at = models.DateTimeField(auto_now=True, verbose_name="更新时间")

View File

@@ -67,7 +67,7 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="btn-group-vertical w-100"> <div class="btn-group-vertical w-100">
<a href="{% url 'yesterday_records' %}" class="btn btn-outline-primary mb-2">记录昨日信息</a> <a href="{% url 'yesterday_records' %}" class="btn btn-outline-primary mb-2">追加昨日信息</a>
<a href="{% url 'today_plan' %}" class="btn btn-outline-primary mb-2">管理今日计划</a> <a href="{% url 'today_plan' %}" class="btn btn-outline-primary mb-2">管理今日计划</a>
<a href="{% url 'generate_report' %}" class="btn btn-outline-primary mb-2">查看今日报告</a> <a href="{% url 'generate_report' %}" class="btn btn-outline-primary mb-2">查看今日报告</a>
<a href="{% url 'send_email' %}" class="btn btn-outline-success">发送今日邮件</a> <a href="{% url 'send_email' %}" class="btn btn-outline-success">发送今日邮件</a>
@@ -100,6 +100,9 @@
{% if reading.progress %} {% if reading.progress %}
<div class="mt-1"><small>进度:{{ reading.progress }}</small></div> <div class="mt-1"><small>进度:{{ reading.progress }}</small></div>
{% endif %} {% endif %}
{% if reading.note %}
<div class="mt-1"><small>笔记:{{ reading.note|truncatechars:100 }}</small></div>
{% endif %}
{% if reading.file %} {% if reading.file %}
<div class="mt-1"> <div class="mt-1">
<a href="{{ reading.file.url }}" class="file-link" target="_blank"><i class="bi bi-file-earmark"></i> 查看附件</a> <a href="{{ reading.file.url }}" class="file-link" target="_blank"><i class="bi bi-file-earmark"></i> 查看附件</a>

View File

@@ -25,6 +25,7 @@
<th>标题</th> <th>标题</th>
<th>来源</th> <th>来源</th>
<th>进度</th> <th>进度</th>
<th>笔记</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
</thead> </thead>
@@ -35,6 +36,7 @@
<td>{{ reading.title }}</td> <td>{{ reading.title }}</td>
<td>{{ reading.source|default:"-" }}</td> <td>{{ reading.source|default:"-" }}</td>
<td>{{ reading.progress|default:"-" }}</td> <td>{{ reading.progress|default:"-" }}</td>
<td>{{ reading.note|truncatechars:50|default:"-" }}</td>
<td> <td>
{% if reading.file %} {% if reading.file %}
<a href="{{ reading.file.url }}" class="btn btn-sm btn-info" title="查看附件" target="_blank"> <a href="{{ reading.file.url }}" class="btn btn-sm btn-info" title="查看附件" target="_blank">