diff --git a/fzjgact/db.sqlite3 b/fzjgact/db.sqlite3 index c60c68b..2175f82 100644 Binary files a/fzjgact/db.sqlite3 and b/fzjgact/db.sqlite3 differ diff --git a/fzjgact/huodong/__pycache__/views.cpython-311.pyc b/fzjgact/huodong/__pycache__/views.cpython-311.pyc index 7eb9af0..f20300a 100644 Binary files a/fzjgact/huodong/__pycache__/views.cpython-311.pyc and b/fzjgact/huodong/__pycache__/views.cpython-311.pyc differ diff --git a/fzjgact/huodong/templates/base.html b/fzjgact/huodong/templates/base.html index aa6d4a7..1fc896d 100644 --- a/fzjgact/huodong/templates/base.html +++ b/fzjgact/huodong/templates/base.html @@ -1,101 +1,103 @@ - -{% load static %} -{% load custom_filters %} - - - - - - 分支机构活动管理 - - - - - -
- 分支机构活动管理 -
- 2025年 -
- - -
- - - - -
- {% block content %} - {% endblock %} -
- - - - -
- - - - - + +{% load static %} +{% load custom_filters %} + + + + + + 分支机构活动管理 + + + + + +
+ 分支机构活动管理 +
+ {{ ''|get_current_year }}年 +
+ 统计周期:{{ ''|get_statistic_period }} +
+ + +
+ + + + +
+ {% block content %} + {% endblock %} +
+ + + + +
+ + + + + \ No newline at end of file diff --git a/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc b/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc index d7b3198..e5930c7 100644 Binary files a/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc and b/fzjgact/huodong/templatetags/__pycache__/custom_filters.cpython-311.pyc differ diff --git a/fzjgact/huodong/templatetags/custom_filters.py b/fzjgact/huodong/templatetags/custom_filters.py index 57f568c..6d778f5 100644 --- a/fzjgact/huodong/templatetags/custom_filters.py +++ b/fzjgact/huodong/templatetags/custom_filters.py @@ -28,3 +28,39 @@ def format_chinese_full_date(value): weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"] weekday = weekdays[date_obj.weekday()] return f"{date_obj.year}年{date_obj.month}月{date_obj.day}日 {weekday}" + + +@register.filter +def get_current_year(value=None): + """ + 获取当前年份 + """ + now = datetime.now() if value is None else value + return now.year + + +@register.filter +def get_statistic_period(value=None): + """ + 计算统计周期 + 规则: + - 在2026年1月,实际统计的是2025年11月至2026年1月 + - 在2026年2月,实际统计的是2025年12月至2026年2月 + - 以此类推 + """ + now = datetime.now() if value is None else value + current_year = now.year + current_month = now.month + + # 计算统计周期的开始月份和年份 + if current_month <= 2: + start_year = current_year - 1 + start_month = 11 + current_month + else: + start_year = current_year + start_month = current_month - 2 + + # 构建统计周期字符串 + period = f"{start_year}年{start_month}月至{current_year}年{current_month}月" + + return period