feat(家庭成员): 添加家庭成员模型并关联感悟和计划
添加家庭成员模型(FamilyMember)并关联到感悟记录(InsightRecord)和今日计划(TodayPlan) 修改相关表单、视图和模板以支持发言人功能 添加数据库迁移文件和初始化脚本 更新报告模板显示发言人信息
This commit is contained in:
@@ -39,7 +39,8 @@ from .models import (
|
||||
InsightRecord,
|
||||
FamilyTask,
|
||||
TodayPlan,
|
||||
SystemConfig
|
||||
SystemConfig,
|
||||
FamilyMember
|
||||
)
|
||||
from .forms import (
|
||||
ReadingRecordForm,
|
||||
@@ -147,6 +148,7 @@ def delete_reading(request, pk):
|
||||
# 添加感悟记录
|
||||
def add_insight(request):
|
||||
"""添加感悟记录"""
|
||||
family_members = FamilyMember.objects.all()
|
||||
if request.method == 'POST':
|
||||
form = InsightRecordForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
@@ -158,13 +160,14 @@ def add_insight(request):
|
||||
else:
|
||||
form = InsightRecordForm()
|
||||
|
||||
context = {'form': form}
|
||||
context = {'form': form, 'family_members': family_members}
|
||||
return render(request, 'core/add_insight.html', context)
|
||||
|
||||
# 编辑感悟记录
|
||||
def edit_insight(request, pk):
|
||||
"""编辑感悟记录"""
|
||||
insight = get_object_or_404(InsightRecord, pk=pk)
|
||||
family_members = FamilyMember.objects.all()
|
||||
if request.method == 'POST':
|
||||
form = InsightRecordForm(request.POST, request.FILES, instance=insight)
|
||||
if form.is_valid():
|
||||
@@ -174,7 +177,7 @@ def edit_insight(request, pk):
|
||||
else:
|
||||
form = InsightRecordForm(instance=insight)
|
||||
|
||||
context = {'form': form, 'insight': insight}
|
||||
context = {'form': form, 'insight': insight, 'family_members': family_members}
|
||||
return render(request, 'core/edit_insight.html', context)
|
||||
|
||||
# 删除感悟记录
|
||||
@@ -257,6 +260,7 @@ def delete_today_reading(request, pk):
|
||||
# 添加今日感悟记录
|
||||
def add_today_insight(request):
|
||||
"""添加今日感悟记录"""
|
||||
family_members = FamilyMember.objects.all()
|
||||
if request.method == 'POST':
|
||||
form = InsightRecordForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
@@ -268,13 +272,14 @@ def add_today_insight(request):
|
||||
else:
|
||||
form = InsightRecordForm()
|
||||
|
||||
context = {'form': form}
|
||||
context = {'form': form, 'family_members': family_members}
|
||||
return render(request, 'core/add_insight.html', context)
|
||||
|
||||
# 编辑今日感悟记录
|
||||
def edit_today_insight(request, pk):
|
||||
"""编辑今日感悟记录"""
|
||||
insight = get_object_or_404(InsightRecord, pk=pk)
|
||||
family_members = FamilyMember.objects.all()
|
||||
if request.method == 'POST':
|
||||
form = InsightRecordForm(request.POST, request.FILES, instance=insight)
|
||||
if form.is_valid():
|
||||
@@ -284,7 +289,7 @@ def edit_today_insight(request, pk):
|
||||
else:
|
||||
form = InsightRecordForm(instance=insight)
|
||||
|
||||
context = {'form': form, 'insight': insight}
|
||||
context = {'form': form, 'insight': insight, 'family_members': family_members}
|
||||
return render(request, 'core/edit_insight.html', context)
|
||||
|
||||
# 删除今日感悟记录
|
||||
@@ -373,6 +378,7 @@ def today_plan(request):
|
||||
# 添加今日计划
|
||||
def add_today_plan(request):
|
||||
"""添加今日计划"""
|
||||
family_members = FamilyMember.objects.all()
|
||||
if request.method == 'POST':
|
||||
form = TodayPlanForm(request.POST)
|
||||
if form.is_valid():
|
||||
@@ -382,13 +388,14 @@ def add_today_plan(request):
|
||||
else:
|
||||
form = TodayPlanForm()
|
||||
|
||||
context = {'form': form}
|
||||
context = {'form': form, 'family_members': family_members}
|
||||
return render(request, 'core/add_today_plan.html', context)
|
||||
|
||||
# 编辑今日计划
|
||||
def edit_today_plan(request, pk):
|
||||
"""编辑今日计划"""
|
||||
plan = get_object_or_404(TodayPlan, pk=pk)
|
||||
family_members = FamilyMember.objects.all()
|
||||
if request.method == 'POST':
|
||||
form = TodayPlanForm(request.POST, instance=plan)
|
||||
if form.is_valid():
|
||||
@@ -398,7 +405,7 @@ def edit_today_plan(request, pk):
|
||||
else:
|
||||
form = TodayPlanForm(instance=plan)
|
||||
|
||||
context = {'form': form, 'plan': plan}
|
||||
context = {'form': form, 'plan': plan, 'family_members': family_members}
|
||||
return render(request, 'core/edit_today_plan.html', context)
|
||||
|
||||
# 删除今日计划
|
||||
|
||||
Reference in New Issue
Block a user