From 9b7b5279db547ebf688170d0d3519d40aa886ba6 Mon Sep 17 00:00:00 2001 From: vicky-ZhuWenqi <72480049+vicky-ZhuWenqi@users.noreply.github.com> Date: Mon, 31 May 2021 08:46:34 +0800 Subject: [PATCH] Update main.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加熟悉和不熟悉按钮功能,如果点熟悉,就将生词簿中该单词后面记录的添加次数减一,直至减为0,就将该单词从生词簿中移除;如果点不熟悉,就将生词簿中该单词后面记录的添加次数加1。 --- app/main.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index 1356f12..6d743bb 100644 --- a/app/main.py +++ b/app/main.py @@ -270,6 +270,17 @@ def user_mark_word(username): return 'Under construction' +@app.route("///unfamiliar", methods=['GET', 'POST']) +def unfamiliar(username,word): + user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) + pickle_idea.unfamiliar(user_freq_record,word) + return redirect(url_for('userpage', username=username)) + +@app.route("///familiar", methods=['GET', 'POST']) +def familiar(username,word): + user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) + pickle_idea.familiar(user_freq_record,word) + return redirect(url_for('userpage', username=username)) @app.route("/", methods=['GET', 'POST']) def userpage(username): @@ -345,13 +356,11 @@ def userpage(username): freq = x[1] if isinstance(d[word], list): # d[word] is a list of dates if freq > 1: - page += '

%s (%d)

\n' % (youdao_link(word), word, '; '.join(d[word]), freq) + page += '

%s(%d) 熟悉 不熟悉

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word) else: - page += '

%s (%d)

\n' % (youdao_link(word), word, '; '.join(d[word]), freq) + page += '

%s(%d) 熟悉 不熟悉

\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word) elif isinstance(d[word], int): # d[word] is a frequency. to migrate from old format. - page += '%s%d\n' % (youdao_link(word), word, freq) - - + page += '%s%d\n' % (youdao_link(word), word, freq) return page ### Sign-up, login, logout ###