fix: Remove 'Assignment Expresions' & Fix annotation words

吴宇涵 2023-03-21 12:42:59 +08:00
parent 1015704e23
commit 48de496caa
2 changed files with 8 additions and 5 deletions

View File

@ -50,7 +50,8 @@ def admin():
context["text_list"] = get_page_articles(_cur_page, _page_size) context["text_list"] = get_page_articles(_cur_page, _page_size)
if request.method == "GET": 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) delete_article(delete_id)
_update_context() _update_context()
else: else:
@ -89,7 +90,8 @@ def add_article(content, source="manual_input", level="5", question="No question
def delete_article(article_id): def delete_article(article_id):
article_id &= 0xFFFFFFFF # max 32 bits article_id &= 0xFFFFFFFF # max 32 bits
with db_session: with db_session:
if article := Article.select(article_id=article_id): article = Article.select(article_id=article_id)
if article:
article.first().delete() article.first().delete()
@ -113,5 +115,6 @@ def get_users():
def update_user_password(username, password="123456"): def update_user_password(username, password="123456"):
with db_session: with db_session:
if user := User.select(name=username).first(): user = User.select(name=username)
user.password = md5(username + password) if user and user.first():
user.first().password = md5(username + password)

View File

@ -1,7 +1,7 @@
from pony.orm import * from pony.orm import *
db = Database() 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): class User(db.Entity):