From af722a89e847e1ca38d486695f9410bd7b6e19f7 Mon Sep 17 00:00:00 2001 From: Tdxdxoz Date: Sun, 27 Dec 2020 19:29:18 +0800 Subject: [PATCH] feat: my_upload and my_fav --- app.py | 11 ++++++++++- templates/list.html | 25 ++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index baa60c5..604ce9e 100644 --- a/app.py +++ b/app.py @@ -129,10 +129,13 @@ def list(username): year = request.args.get('year') year = year and year.isdigit() and int(year) + is_my_upload = request.args.get('my_upload') + is_my_fav = request.args.get('my_fav') + has_course = course is not None has_teacher = teacher is not None has_year = year is not None - ept = not (has_course or has_teacher or has_year) and 'page' not in request.args + ept = not (has_course or has_teacher or has_year) and is_my_fav is None and is_my_upload is None and 'page' not in request.args ps = Paper.query @@ -143,6 +146,12 @@ def list(username): if year or year==0: ps = ps.filter_by(year=year) + if is_my_upload: + ps = ps.filter_by(author=username) + if is_my_fav: + ps = ps.join(LikeRelation, Paper.id==LikeRelation.paper_id and LikeRelation.username==username) + + ps = ps.order_by(db.desc('like_num')) pagination = ps.paginate(max_per_page=100) curr_year = date.today().year diff --git a/templates/list.html b/templates/list.html index f0138cf..d7980c0 100644 --- a/templates/list.html +++ b/templates/list.html @@ -177,6 +177,13 @@ margin-bottom: 8px; } + .user-info { + position: fixed; + top: 0; + right: 0; + z-index: 1030 + } + .user-info:not(:hover) div:not(.show) .username{ display: none; } @@ -209,7 +216,7 @@

华清大学
 课程攻略
  共享计划

-
+ -
+

*点击某一课程/教师/年份进行筛选

+
+ {% if is_my_upload %} + 我的上传 + {% endif %} + {% if is_my_fav %} + 我的点赞 + {% endif %} +
{% for p in pagination.items %}