From f4d7dfd8d097b9bd515914e554b3021fc8559557 Mon Sep 17 00:00:00 2001 From: xiaji Date: Mon, 9 Mar 2026 10:56:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(=E5=AE=B6=E5=BA=AD=E4=BA=8B=E9=A1=B9):?= =?UTF-8?q?=20=E8=BF=87=E6=BB=A4=E5=B7=B2=E6=88=AA=E6=AD=A2=E7=9A=84?= =?UTF-8?q?=E4=BA=8B=E9=A1=B9=EF=BC=8C=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E6=97=A5=E6=9C=9F=E6=97=A9=E4=BA=8E=E4=BB=8A=E5=A4=A9?= =?UTF-8?q?=E7=9A=84=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/views.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/views.py b/core/views.py index abbb7dd..37b5368 100644 --- a/core/views.py +++ b/core/views.py @@ -1,7 +1,7 @@ from django.shortcuts import render, redirect, get_object_or_404 from django.http import HttpResponse, JsonResponse from django.utils import timezone -from django.db.models import Count +from django.db.models import Count, Q from django.core.mail import send_mail, EmailMessage from django.conf import settings from django.views.decorators.csrf import csrf_exempt @@ -74,8 +74,10 @@ def index(request): today_plan = TodayPlan.objects.filter(date=today) - # 获取未完成的家庭事项(排除已完成状态) + # 获取未完成的家庭事项(排除已完成状态和已截止的事项) pending_family_tasks = FamilyTask.objects.exclude(status__name='completed') + # 过滤掉截止日期早于今天的事项(如果设置了截止日期) + pending_family_tasks = pending_family_tasks.filter(Q(deadline__gte=today) | Q(deadline__isnull=True)) context = { 'yesterday': yesterday, @@ -397,10 +399,12 @@ def delete_summary(request, pk): # 家庭事项视图 @login_required def family_tasks(request): - """家庭事项 - 显示所有未完成的事项(非completed状态)""" + """家庭事项 - 显示所有未完成的事项(非completed状态且未截止)""" logger.info("用户访问家庭事项页面") - # 排除已完成的事项,显示所有未完成的事项 + today = timezone.now().date() + # 排除已完成的事项和已截止的事项 tasks = FamilyTask.objects.exclude(status__name='completed') + tasks = tasks.filter(Q(deadline__gte=today) | Q(deadline__isnull=True)) context = { 'tasks': tasks, From d886dae6d864a5e9bebdf5ef488d7bb4eed82f77 Mon Sep 17 00:00:00 2001 From: xiaji Date: Mon, 9 Mar 2026 12:33:44 +0800 Subject: [PATCH 2/5] =?UTF-8?q?style(=E9=A1=B5=E8=84=9A):=20=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E4=B8=BA=E5=BD=93=E5=89=8D=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=97=B6=E5=88=86=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/templates/core/base.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/templates/core/base.html b/core/templates/core/base.html index 16625a7..148fd01 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -1,4 +1,3 @@ -{% load git_info %} @@ -538,7 +537,7 @@

- 代码最后更新:{% git_last_commit_time %} + 更新时间:{% now "Y-m-d H:i:s" %}

From 5a127e7fd711c52b2a1e2a5ca303426e207fe2d5 Mon Sep 17 00:00:00 2001 From: xiaji Date: Mon, 9 Mar 2026 14:03:44 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat(=E9=A6=96=E9=A1=B5):=20=E6=9C=AA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=97=B6=E9=9A=90=E8=97=8F=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=EF=BC=8C=E5=8F=AA=E6=98=BE=E7=A4=BA=E7=AE=80?= =?UTF-8?q?=E5=8D=95=E6=AC=A2=E8=BF=8E=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/templates/core/base.html | 4 ++++ core/templates/core/index.html | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/templates/core/base.html b/core/templates/core/base.html index 148fd01..57ad7ba 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -448,6 +448,7 @@ 首页 + {% if user.is_authenticated %} + {% endif %} diff --git a/core/templates/core/index.html b/core/templates/core/index.html index 5c294a8..93d063a 100644 --- a/core/templates/core/index.html +++ b/core/templates/core/index.html @@ -1,6 +1,7 @@ {% extends 'core/base.html' %} {% block content %} +{% if user.is_authenticated %}
@@ -372,4 +373,21 @@ setCurrentYear(); }); +{% else %} + +
+
+
+
+ +

欢迎使用家庭日报系统

+

请先登录以使用系统功能

+ + 登录系统 + +
+
+
+
+{% endif %} {% endblock %} From e568f92c3c30f5708681e3df116afd5e74e170b5 Mon Sep 17 00:00:00 2001 From: xiaji Date: Mon, 9 Mar 2026 14:23:42 +0800 Subject: [PATCH 4/5] =?UTF-8?q?style(=E9=A1=B5=E8=84=9A):=20=E6=94=B9?= =?UTF-8?q?=E5=9B=9E=E6=98=BE=E7=A4=BAgit=E6=8F=90=E4=BA=A4=E6=97=B6?= =?UTF-8?q?=E9=97=B4=EF=BC=8C=E8=80=8C=E4=B8=8D=E6=98=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/templates/core/base.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/templates/core/base.html b/core/templates/core/base.html index 57ad7ba..a5679d7 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -1,3 +1,4 @@ +{% load git_info %} @@ -541,7 +542,7 @@

- 更新时间:{% now "Y-m-d H:i:s" %} + 更新时间:{% git_last_commit_time %}

From a3e9de5af22f5d808fb9c8a9bdc981f78005c235 Mon Sep 17 00:00:00 2001 From: xiaji Date: Mon, 9 Mar 2026 15:11:45 +0800 Subject: [PATCH 5/5] =?UTF-8?q?feat(=E5=85=AC=E5=BC=80=E5=86=85=E5=AE=B9):?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E5=85=AC=E5=BC=80=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=92=8C=E8=BD=AF=E4=BB=B6=E4=B8=8B=E8=BD=BD=EF=BC=8C=E6=97=A0?= =?UTF-8?q?=E9=9C=80=E7=99=BB=E5=BD=95=E5=8D=B3=E5=8F=AF=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/admin.py | 16 ++++ core/forms.py | 20 ++++- core/models.py | 34 ++++++++ core/templates/core/add_public_content.html | 76 ++++++++++++++++++ core/templates/core/base.html | 5 ++ .../templates/core/delete_public_content.html | 48 +++++++++++ core/templates/core/edit_public_content.html | 76 ++++++++++++++++++ core/templates/core/public_content.html | 80 +++++++++++++++++++ core/urls.py | 6 ++ core/views.py | 74 ++++++++++++++++- 10 files changed, 431 insertions(+), 4 deletions(-) create mode 100644 core/templates/core/add_public_content.html create mode 100644 core/templates/core/delete_public_content.html create mode 100644 core/templates/core/edit_public_content.html create mode 100644 core/templates/core/public_content.html diff --git a/core/admin.py b/core/admin.py index da9e09b..fbd798c 100644 --- a/core/admin.py +++ b/core/admin.py @@ -13,6 +13,8 @@ from .models import ( FamilyTask, TodayPlan, SystemConfig, + PublicContentType, + PublicContent, ) @@ -96,3 +98,17 @@ class TodayPlanAdmin(admin.ModelAdmin): @admin.register(SystemConfig) class SystemConfigAdmin(admin.ModelAdmin): list_display = ('smtp_server', 'smtp_port', 'smtp_username', 'recipient_email', 'send_time', 'created_at') + + +@admin.register(PublicContentType) +class PublicContentTypeAdmin(admin.ModelAdmin): + list_display = ('name', 'created_at', 'updated_at') + search_fields = ('name',) + + +@admin.register(PublicContent) +class PublicContentAdmin(admin.ModelAdmin): + list_display = ('title', 'type', 'is_published', 'sort_order', 'created_at') + list_filter = ('type', 'is_published') + search_fields = ('title', 'content') + ordering = ('sort_order', '-created_at') diff --git a/core/forms.py b/core/forms.py index 66e9639..66f0914 100644 --- a/core/forms.py +++ b/core/forms.py @@ -8,7 +8,8 @@ from .models import ( FamilyTask, TodayPlan, SystemConfig, - FamilyMember + FamilyMember, + PublicContent ) class ReadingRecordForm(forms.ModelForm): @@ -109,4 +110,19 @@ class SystemConfigForm(forms.ModelForm): if not re.match(email_pattern, recipient_email): logger.warning(f"收件人邮箱格式不正确: {recipient_email}") raise forms.ValidationError("请输入有效的邮箱地址,格式如:example@domain.com") - return recipient_email \ No newline at end of file + return recipient_email + + +class PublicContentForm(forms.ModelForm): + """公开内容表单""" + class Meta: + model = PublicContent + fields = ['type', 'title', 'content', 'file', 'url', 'sort_order', 'is_published'] + widgets = { + 'type': forms.Select(attrs={'class': 'form-select'}), + 'title': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入标题'}), + 'content': forms.Textarea(attrs={'class': 'form-control', 'rows': 5, 'placeholder': '请输入内容'}), + 'file': forms.FileInput(attrs={'class': 'form-control'}), + 'url': forms.URLInput(attrs={'class': 'form-control', 'placeholder': '请输入链接地址'}), + 'sort_order': forms.NumberInput(attrs={'class': 'form-control', 'placeholder': '请输入排序值'}), + } \ No newline at end of file diff --git a/core/models.py b/core/models.py index 914b283..3c8d24d 100644 --- a/core/models.py +++ b/core/models.py @@ -216,3 +216,37 @@ class SystemConfig(models.Model): """获取系统配置,单例模式""" config, created = cls.objects.get_or_create(pk=1) return config + +class PublicContentType(models.Model): + """公开内容类型""" + name = models.CharField(max_length=20, unique=True, verbose_name="名称") + created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") + updated_at = models.DateTimeField(auto_now=True, verbose_name="更新时间") + + class Meta: + verbose_name = "公开内容类型" + verbose_name_plural = "公开内容类型" + ordering = ['name'] + + def __str__(self): + return self.name + +class PublicContent(models.Model): + """公开内容表""" + type = models.ForeignKey(PublicContentType, on_delete=models.CASCADE, verbose_name="类型") + title = models.CharField(max_length=200, verbose_name="标题") + content = models.TextField(blank=True, null=True, verbose_name="内容") + file = models.FileField(upload_to='public_files/', blank=True, null=True, verbose_name="上传文件") + url = models.URLField(blank=True, null=True, verbose_name="链接地址") + sort_order = models.IntegerField(default=0, verbose_name="排序") + is_published = models.BooleanField(default=True, verbose_name="是否发布") + created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") + updated_at = models.DateTimeField(auto_now=True, verbose_name="更新时间") + + class Meta: + verbose_name = "公开内容" + verbose_name_plural = "公开内容" + ordering = ['sort_order', '-created_at'] + + def __str__(self): + return f"{self.type.name} - {self.title}" diff --git a/core/templates/core/add_public_content.html b/core/templates/core/add_public_content.html new file mode 100644 index 0000000..88729d2 --- /dev/null +++ b/core/templates/core/add_public_content.html @@ -0,0 +1,76 @@ +{% extends 'core/base.html' %} + +{% block content %} + +
+

+ 添加公开内容 +

+ + 返回 + +
+ +
+
+
+
+
+ 填写公开内容信息 +
+
+
+
+ {% csrf_token %} + + {% for field in form %} +
+ + {{ field }} + {% if field.help_text %} +
{{ field.help_text }}
+ {% endif %} + {% for error in field.errors %} +
+ {{ error }} +
+ {% endfor %} +
+ {% endfor %} + +
+ + + 取消 + +
+
+
+
+
+
+{% endblock %} diff --git a/core/templates/core/base.html b/core/templates/core/base.html index a5679d7..5a156ba 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -449,6 +449,11 @@ 首页 + {% if user.is_authenticated %}