删除每个页面上单独查询公告的逻辑,改为使用 templatetag 实现。

This commit is contained in:
virusdefender
2015-09-11 23:10:54 +08:00
parent c1e0c7cd3a
commit d6499c71aa
6 changed files with 19 additions and 21 deletions

View File

@@ -255,8 +255,6 @@ def problem_list_page(request, page=1):
except Exception:
pass
# 右侧的公告列表
announcements = Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
# 右侧标签列表 按照关联的题目的数量排序 排除题目数量为0的
tags = ProblemTag.objects.annotate(problem_number=Count("problem")).filter(problem_number__gt=0).order_by("-problem_number")
@@ -264,4 +262,4 @@ def problem_list_page(request, page=1):
{"problems": current_page, "page": int(page),
"previous_page": previous_page, "next_page": next_page,
"keyword": keyword, "tag": tag_text,
"announcements": announcements, "tags": tags})
"tags": tags})