userpaget_get.html: Resolve merge conflicts
commit
66899376c3
|
@ -79,18 +79,18 @@ def article():
|
|||
"username": session.get("username"),
|
||||
}
|
||||
|
||||
|
||||
if request.method == "GET":
|
||||
try:
|
||||
delete_id = int(request.args.get("delete_id", 0))
|
||||
except:
|
||||
return "Delete article ID must be integer!"
|
||||
if delete_id: # delete article
|
||||
delete_article_by_id(delete_id)
|
||||
_update_context()
|
||||
|
||||
elif request.method == "POST":
|
||||
if request.method == "POST":
|
||||
data = request.form
|
||||
|
||||
if "delete_id" in data:
|
||||
try:
|
||||
delete_id = int(data["delete_id"]) # 转成int型
|
||||
delete_article_by_id(delete_id) # 根据id删除article
|
||||
flash(f'Article ID {delete_id} deleted successfully.') # 刷新页首提示语
|
||||
_update_context()
|
||||
except ValueError:
|
||||
flash('Invalid article ID for deletion.') # 刷新页首提示语
|
||||
|
||||
content = data.get("content", "")
|
||||
source = data.get("source", "")
|
||||
question = data.get("question", "")
|
||||
|
@ -99,9 +99,9 @@ def article():
|
|||
if level not in ['1', '2', '3', '4']:
|
||||
return "Level must be between 1 and 4."
|
||||
add_article(content, source, level, question)
|
||||
_update_context()
|
||||
title = content.split('\n')[0]
|
||||
flash(f'Article added. Title: {title}')
|
||||
_update_context() # 这行应在flash之后 否则会发生新建的文章即点即删
|
||||
|
||||
return render_template("admin_manage_article.html", **context)
|
||||
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes" />
|
||||
<meta name="format-detection" content="telephone=no" />
|
||||
<link href="../static/css/bootstrap.css" rel="stylesheet">
|
||||
<script>
|
||||
function confirmDeletion(articleId, articleTitle) {
|
||||
return confirm(`确认删除文章 "${articleTitle}" (ID: ${articleId}) 吗?`);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="container" style="width: 800px; margin: auto; margin-top:24px;">
|
||||
|
@ -66,9 +71,10 @@
|
|||
<div class="list-group">
|
||||
{% for text in text_list %}
|
||||
<div class="list-group-item list-group-item-action" aria-current="true">
|
||||
<div>
|
||||
<a type="button" href="/admin/article?delete_id={{text.article_id}}" class="btn btn-outline-danger btn-sm">删除</a>
|
||||
</div>
|
||||
<form action="/admin/article" method="post" style="display: inline;">
|
||||
<input type="hidden" name="delete_id" value="{{ text.article_id }}">
|
||||
<button type="submit" class="btn btn-outline-danger btn-sm" onclick="return confirmDeletion('{{ text.article_id }}', '{{ text.title }}')">删除</button>
|
||||
</form>
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h5 class="mb-1">{{ text.title }}</h5>
|
||||
</div>
|
||||
|
|
|
@ -66,7 +66,6 @@
|
|||
|
||||
</p>
|
||||
{% for message in get_flashed_messages() %}
|
||||
|
||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||
{{ message }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
|
@ -89,7 +88,6 @@
|
|||
</div>
|
||||
|
||||
<p><b id="question">{{ today_article['question'] }}</b></p><br/>
|
||||
|
||||
<script type="text/javascript">
|
||||
function toggle_visibility(id) { {# https://css-tricks.com/snippets/javascript/showhide-element/#}
|
||||
const e = document.getElementById(id);
|
||||
|
@ -114,7 +112,6 @@
|
|||
<input type="checkbox" id="highlightCheckbox" onclick="toggleHighlighting()" />生词高亮
|
||||
<input type="checkbox" id="readCheckbox" onclick="onReadClick()" />大声朗读
|
||||
<input type="checkbox" id="chooseCheckbox" onclick="onChooseClick()" />划词入库
|
||||
|
||||
<div class="range">
|
||||
<div class="field">
|
||||
<div class="sliderValue">
|
||||
|
|
Loading…
Reference in New Issue