- {% if today_article %}
+ {% if result_of_generate_article == 'found' %}
diff --git a/app/user_service.py b/app/user_service.py
index a306724..4f81c6e 100644
--- a/app/user_service.py
+++ b/app/user_service.py
@@ -31,7 +31,10 @@ def user_reset(username):
'''
if request.method == 'GET':
had_read_articles = session.get("had_read_articles")
- had_read_articles["index"] += 1
+ if had_read_articles['article_ids'][-1] == "null": # 如果当前还是“null”,则将“null”pop出来,无需index+=1
+ had_read_articles['article_ids'].pop()
+ else: # 当前不为“null”,直接 index+=1
+ had_read_articles["index"] += 1
session["had_read_articles"] = had_read_articles
return redirect(url_for('user_bp.userpage', username=username))
else:
@@ -45,10 +48,11 @@ def user_back(username):
:return: 返回页面内容
'''
if request.method == 'GET':
- if session.get("found_article"):
- had_read_articles = session.get("had_read_articles")
- had_read_articles["index"] -= 1
- session["had_read_articles"] = had_read_articles
+ had_read_articles = session.get("had_read_articles")
+ had_read_articles["index"] -= 1 # 上一篇,index-=1
+ if had_read_articles['article_ids'][-1] == "null": # 如果当前还是“null”,则将“null”pop出来
+ had_read_articles['article_ids'].pop()
+ session["had_read_articles"] = had_read_articles
return redirect(url_for('user_bp.userpage', username=username))
@@ -137,10 +141,6 @@ def userpage(username):
words += x[0] + ' '
had_read_articles, today_article, result_of_generate_article = get_today_article(user_freq_record, session.get('had_read_articles'))
session['had_read_articles'] = had_read_articles
- if today_article is None:
- session["found_article"] = False
- else:
- session["found_article"] = True
# 通过 today_article,加载前端的显示页面
return render_template('userpage_get.html',
username=username,
From fc3e27488b3b55c1013a970e6abb95b88caff9aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=80=E9=97=AE=E4=B8=89=E4=B8=8D=E7=9F=A5?=
<178428409@qq.com>
Date: Fri, 21 Apr 2023 05:33:26 +0800
Subject: [PATCH 07/10] =?UTF-8?q?=E7=BB=99=E6=A0=87=E7=AD=BE=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0id=EF=BC=8C=E6=96=B9=E4=BE=BF=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/templates/userpage_get.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html
index 68948df..cb892db 100644
--- a/app/templates/userpage_get.html
+++ b/app/templates/userpage_get.html
@@ -37,7 +37,7 @@
English Pal for {{ username }}
- 退出
+ 退出
重设密码
{# {% for message in flashed_messages %}#} {# 根据user_service.userpage,取消了参数flashed_messages,因此注释了这段代码 #}
From 58d7349afe69c5934754cb7a5145b33382326c37 Mon Sep 17 00:00:00 2001
From: Hui Lan
Date: Tue, 25 Apr 2023 08:40:26 +0800
Subject: [PATCH 08/10] Change from bug359-zhangkeli
---
app/pickle_idea2.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/pickle_idea2.py b/app/pickle_idea2.py
index 4055fc4..0da55bc 100644
--- a/app/pickle_idea2.py
+++ b/app/pickle_idea2.py
@@ -68,7 +68,7 @@ def save_frequency_to_pickle(d, pickle_fname):
d2 = {}
for k in d:
if not k in exclusion_lst and not k.isnumeric() and not len(k) < 2:
- d2[k] = list(sorted(set(d[k])))
+ d2[k] = list(sorted(d[k])) # 原先这里是d2[k] = list(sorted(set(d[k])))
pickle.dump(d2, f)
f.close()
From 6be035f2828286b5cd59f15ec04336b86c3cb0fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=80=E9=97=AE=E4=B8=89=E4=B8=8D=E7=9F=A5?=
<178428409@qq.com>
Date: Tue, 25 Apr 2023 11:38:01 +0800
Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E6=B2=A1?=
=?UTF-8?q?=E6=9C=89=E6=89=BE=E5=88=B0=E6=96=87=E7=AB=A0=E6=88=96=E8=80=85?=
=?UTF-8?q?=E6=96=87=E7=AB=A0=E8=AF=BB=E5=AE=8C=E6=97=B6=EF=BC=8C=E7=9B=B4?=
=?UTF-8?q?=E6=8E=A5=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E6=88=96=E8=80=85?=
=?UTF-8?q?session=E4=B8=8D=E5=85=B3=E9=97=AD=E9=87=8D=E6=96=B0=E8=BF=9B?=
=?UTF-8?q?=E5=85=A5=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=AF=BC=E8=87=B4=E7=9A=84?=
=?UTF-8?q?=E9=94=99=E8=AF=AF=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Article.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/Article.py b/app/Article.py
index aac2c81..35a06a4 100644
--- a/app/Article.py
+++ b/app/Article.py
@@ -42,6 +42,9 @@ def get_today_article(user_word_list, had_read_articles):
if had_read_articles["index"] > len(had_read_articles["article_ids"])-1: # 生成新的文章,因此查找所有的文章
rq.instructions("SELECT * FROM article")
else: # 生成阅读过的文章,因此查询指定 article_id 的文章
+ if had_read_articles["article_ids"][had_read_articles["index"]] == 'null': # 可能因为直接刷新页面导致直接去查询了'null',因此当刷新的页面的时候,需要直接进行“上一篇”操作
+ had_read_articles["index"] -= 1
+ had_read_articles["article_ids"].pop()
rq.instructions('SELECT * FROM article WHERE article_id=%d' % (had_read_articles["article_ids"][had_read_articles["index"]]))
rq.do()
result = rq.get_results()
From 5654fbf9bc3ae85eec621a4e6e2ecd1f6c6c3b30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=80=E9=97=AE=E4=B8=89=E4=B8=8D=E7=9F=A5?=
<178428409@qq.com>
Date: Wed, 26 Apr 2023 18:49:59 +0800
Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E4=BD=BF?=
=?UTF-8?q?=E7=94=A8=E6=96=B0=E7=9A=84//userpage=E8=B7=AF?=
=?UTF-8?q?=E7=94=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/templates/admin_index.html | 2 +-
app/templates/mainpage_get.html | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/templates/admin_index.html b/app/templates/admin_index.html
index 68ee68f..f62a137 100644
--- a/app/templates/admin_index.html
+++ b/app/templates/admin_index.html
@@ -30,7 +30,7 @@
diff --git a/app/templates/mainpage_get.html b/app/templates/mainpage_get.html
index 3594571..344943d 100644
--- a/app/templates/mainpage_get.html
+++ b/app/templates/mainpage_get.html
@@ -23,7 +23,7 @@