feat(汇总记录): 添加汇总记录功能及相关页面
实现汇总记录的CRUD功能,包括: - 添加URL路由 - 创建添加、编辑、删除和列表页面 - 在导航栏和首页添加相关链接 - 实现汇总记录的展示和操作功能
This commit is contained in:
27
core/templates/core/add_summary.html
Normal file
27
core/templates/core/add_summary.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{% extends 'core/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h2>添加汇总记录</h2>
|
||||
|
||||
<form method="post" enctype="multipart/form-data" class="mt-4">
|
||||
{% csrf_token %}
|
||||
|
||||
{% for field in form %}
|
||||
<div class="mb-3">
|
||||
<label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
{% if field.help_text %}
|
||||
<div class="form-text">{{ field.help_text }}</div>
|
||||
{% endif %}
|
||||
{% for error in field.errors %}
|
||||
<div class="invalid-feedback d-block">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="mt-4">
|
||||
<button type="submit" class="btn btn-primary">保存</button>
|
||||
<a href="{% url 'summaries' %}" class="btn btn-secondary">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -49,6 +49,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if request.resolver_match.url_name == 'yesterday_records' or 'add_reading' in request.path or 'edit_reading' in request.path or 'add_insight' in request.path or 'edit_insight' in request.path %}active{% endif %}" href="{% url 'yesterday_records' %}">昨日记录</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if request.resolver_match.url_name == 'summaries' or 'add_summary' in request.path or 'edit_summary' in request.path %}active{% endif %}" href="{% url 'summaries' %}">汇总记录</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if request.resolver_match.url_name == 'family_tasks' or 'add_family_task' in request.path or 'edit_family_task' in request.path %}active{% endif %}" href="{% url 'family_tasks' %}">家庭事项</a>
|
||||
</li>
|
||||
|
||||
55
core/templates/core/delete_summary.html
Normal file
55
core/templates/core/delete_summary.html
Normal file
@@ -0,0 +1,55 @@
|
||||
{% extends 'core/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h2>删除汇总记录</h2>
|
||||
|
||||
<div class="alert alert-warning mt-4">
|
||||
<p>确定要删除以下汇总记录吗?此操作不可恢复。</p>
|
||||
</div>
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header bg-danger text-white">
|
||||
<h5 class="card-title mb-0">汇总记录详情</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th style="width: 150px;">日期</th>
|
||||
<td>{{ summary.date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>分类</th>
|
||||
<td>{{ summary.category.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>发言人</th>
|
||||
<td>{{ summary.speaker.name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>内容</th>
|
||||
<td>{{ summary.content }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>来源</th>
|
||||
<td>{{ summary.source|default:"-" }}</td>
|
||||
</tr>
|
||||
{% if summary.file %}
|
||||
<tr>
|
||||
<th>附件</th>
|
||||
<td>
|
||||
<a href="{{ summary.file.url }}" target="_blank">{{ summary.file.name }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form method="post" class="mt-4">
|
||||
{% csrf_token %}
|
||||
<div class="mt-4">
|
||||
<button type="submit" class="btn btn-danger">确认删除</button>
|
||||
<a href="{% url 'summaries' %}" class="btn btn-secondary">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
27
core/templates/core/edit_summary.html
Normal file
27
core/templates/core/edit_summary.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{% extends 'core/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h2>编辑汇总记录</h2>
|
||||
|
||||
<form method="post" enctype="multipart/form-data" class="mt-4">
|
||||
{% csrf_token %}
|
||||
|
||||
{% for field in form %}
|
||||
<div class="mb-3">
|
||||
<label for="{{ field.id_for_label }}" class="form-label">{{ field.label }}</label>
|
||||
{{ field }}
|
||||
{% if field.help_text %}
|
||||
<div class="form-text">{{ field.help_text }}</div>
|
||||
{% endif %}
|
||||
{% for error in field.errors %}
|
||||
<div class="invalid-feedback d-block">{{ error }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="mt-4">
|
||||
<button type="submit" class="btn btn-primary">保存</button>
|
||||
<a href="{% url 'summaries' %}" class="btn btn-secondary">取消</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -138,6 +138,33 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 昨日汇总记录 -->
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-12">
|
||||
<h5>汇总记录</h5>
|
||||
{% if yesterday_summary %}
|
||||
<ul class="list-group">
|
||||
{% for summary in yesterday_summary %}
|
||||
<li class="list-group-item">
|
||||
<strong>{{ summary.category.name }}</strong> - {{ summary.speaker.name }}
|
||||
<div class="mt-1">{{ summary.content }}</div>
|
||||
{% if summary.source %}
|
||||
<small class="text-muted">来源:{{ summary.source }}</small>
|
||||
{% endif %}
|
||||
{% if summary.file %}
|
||||
<div class="mt-1">
|
||||
<a href="{{ summary.file.url }}" class="file-link" target="_blank"><i class="bi bi-file-earmark"></i> 查看附件</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-muted">昨日没有汇总记录</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
59
core/templates/core/summaries.html
Normal file
59
core/templates/core/summaries.html
Normal file
@@ -0,0 +1,59 @@
|
||||
{% extends 'core/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h2>汇总记录 ({{ yesterday }})</h2>
|
||||
|
||||
<div class="mb-4">
|
||||
<a href="{% url 'add_summary' %}" class="btn btn-primary">添加汇总记录</a>
|
||||
</div>
|
||||
|
||||
{% if summary_records %}
|
||||
<div class="card">
|
||||
<div class="card-header bg-info text-white">
|
||||
<h5 class="card-title mb-0">汇总记录列表</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>分类</th>
|
||||
<th>发言人</th>
|
||||
<th>内容</th>
|
||||
<th>来源</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for summary in summary_records %}
|
||||
<tr>
|
||||
<td>{{ summary.category.name }}</td>
|
||||
<td>{{ summary.speaker.name }}</td>
|
||||
<td>{{ summary.content|truncatechars:100 }}</td>
|
||||
<td>{{ summary.source|default:"-" }}</td>
|
||||
<td>
|
||||
{% if summary.file %}
|
||||
<a href="{{ summary.file.url }}" class="btn btn-sm btn-info" title="查看附件" target="_blank">
|
||||
<i class="bi bi-file-earmark"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{% url 'edit_summary' summary.id %}" class="btn btn-sm btn-warning" title="编辑">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<a href="{% url 'delete_summary' summary.id %}" class="btn btn-sm btn-danger" title="删除">
|
||||
<i class="bi bi-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p class="text-muted">昨日没有汇总记录,点击上方按钮添加</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -23,6 +23,12 @@ urlpatterns = [
|
||||
path('today/insight/<int:pk>/edit/', views.edit_today_insight, name='edit_today_insight'),
|
||||
path('today/insight/<int:pk>/delete/', views.delete_today_insight, name='delete_today_insight'),
|
||||
|
||||
# 汇总记录
|
||||
path('summaries/', views.summaries, name='summaries'),
|
||||
path('summaries/add/', views.add_summary, name='add_summary'),
|
||||
path('summaries/<int:pk>/edit/', views.edit_summary, name='edit_summary'),
|
||||
path('summaries/<int:pk>/delete/', views.delete_summary, name='delete_summary'),
|
||||
|
||||
# 家庭事项
|
||||
path('family-tasks/', views.family_tasks, name='family_tasks'),
|
||||
path('family-tasks/add/', views.add_family_task, name='add_family_task'),
|
||||
|
||||
Reference in New Issue
Block a user