From f4df263d6ea29c3019ce479ee2b67d0b403551f0 Mon Sep 17 00:00:00 2001
From: Lan Hui <1348141770@qq.com>
Date: Fri, 11 Aug 2023 19:14:51 +0800
Subject: [PATCH] Flash message is informative. Why not add it?
---
app/static/.DS_Store | Bin 0 -> 6148 bytes
app/templates/userpage_get.html | 6 +++---
app/user_service.py | 6 +++++-
3 files changed, 8 insertions(+), 4 deletions(-)
create mode 100644 app/static/.DS_Store
diff --git a/app/static/.DS_Store b/app/static/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..0c9d7b0bb4d3e8b93b39ac16f84d7f721cd3279b
GIT binary patch
literal 6148
zcmeHK%Sr=55Ukc5B3^RLael!+7()Dl{D7b_7g;e7!P}nlU4EL?55%zX67V9`&|Nb<
zU9)T*wzmP;>hN?2EC9^ujyQUlnxDH*?5Z+Gr1Opgwixh;kN3@_`h3ET;uT;Ht@^ap58~uUqHJ@}hu7ko5?U)$t
hm>X}$%P7ja=4+n!!Z9)E%m重设密码
-{# {% for message in flashed_messages %}#} {# 根据user_service.userpage,取消了参数flashed_messages,因此注释了这段代码 #}
-{# Congratulations! {{ message }}
#}
-{# {% endfor %}#}
+ {% for message in get_flashed_messages() %}
+ {{ message }}
+ {% endfor %}
diff --git a/app/user_service.py b/app/user_service.py
index 6c208dc..27323b8 100644
--- a/app/user_service.py
+++ b/app/user_service.py
@@ -181,7 +181,11 @@ def user_mark_word(username):
for word in request.form.getlist('marked'):
lst.append((word, [get_time()]))
d = pickle_idea2.merge_frequency(lst, lst_history)
- pickle_idea2.save_frequency_to_pickle(d, user_freq_record)
+ if len(lst_history) > 999:
+ flash('You have way too many words in your difficult-words book. Delete some first.')
+ else:
+ pickle_idea2.save_frequency_to_pickle(d, user_freq_record)
+ flash('Added %s.' % (', '.join(request.form.getlist('marked'))))
return redirect(url_for('user_bp.userpage', username=username))
else:
return 'Under construction'