From 48de496caa31ebfa6294beb7ca62917566ea1c18 Mon Sep 17 00:00:00 2001 From: Awoodwhale Date: Tue, 21 Mar 2023 12:42:59 +0800 Subject: [PATCH] fix: Remove 'Assignment Expresions' & Fix annotation words --- app/admin_service.py | 11 +++++++---- app/model.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/admin_service.py b/app/admin_service.py index 2ed9768..2893434 100644 --- a/app/admin_service.py +++ b/app/admin_service.py @@ -50,7 +50,8 @@ def admin(): context["text_list"] = get_page_articles(_cur_page, _page_size) if request.method == "GET": - if delete_id := int(request.args.get("delete_id", 0)): # delete article + delete_id = int(request.args.get("delete_id", 0)) + if delete_id: # delete article delete_article(delete_id) _update_context() else: @@ -89,7 +90,8 @@ def add_article(content, source="manual_input", level="5", question="No question def delete_article(article_id): article_id &= 0xFFFFFFFF # max 32 bits with db_session: - if article := Article.select(article_id=article_id): + article = Article.select(article_id=article_id) + if article: article.first().delete() @@ -113,5 +115,6 @@ def get_users(): def update_user_password(username, password="123456"): with db_session: - if user := User.select(name=username).first(): - user.password = md5(username + password) + user = User.select(name=username) + if user and user.first(): + user.first().password = md5(username + password) diff --git a/app/model.py b/app/model.py index a913e65..bc8a08a 100644 --- a/app/model.py +++ b/app/model.py @@ -1,7 +1,7 @@ from pony.orm import * db = Database() -db.bind("sqlite", "./static/wordfreqapp.db", create_db=True) # bind sqlit file +db.bind("sqlite", "./static/wordfreqapp.db", create_db=True) # bind sqlite file class User(db.Entity):