完善老师页面,数据管理增加按key筛查

This commit is contained in:
DSQ
2026-03-15 16:54:08 +08:00
parent 6f1abc1681
commit 8c4e4e4c0d
6 changed files with 169 additions and 12 deletions

View File

@@ -41,8 +41,10 @@
<div class="navigation-links">
<a href="{% url 'main:home' %}" onclick="return handleNavClick(this, '/');">主页</a>
<a href="{% url 'elastic:upload_page' %}" onclick="return handleNavClick(this, '/elastic/upload/');">图片上传与识别</a>
{% if is_admin %}
{% if is_admin or has_manage_key %}
<a href="{% url 'elastic:manage_page' %}" onclick="return handleNavClick(this, '/elastic/manage/');">数据管理</a>
{% endif %}
{% if is_admin %}
<a href="{% url 'elastic:user_manage' %}" onclick="return handleNavClick(this, '/elastic/user_manage/');">用户管理</a>
{% endif %}
<a href="/accounts/profile/">个人中心</a>
@@ -306,4 +308,4 @@
loadRecent();
</script>
</body>
</html>
</html>

View File

@@ -10,9 +10,7 @@ def home(request):
if session_user_id is None:
return redirect("/accounts/login/")
# Show user_id (prefer query param if present, but don't trust it)
user_id_qs = request.GET.get("user_id")
uid = user_id_qs or session_user_id
uid = session_user_id
perm = request.session.get("permission")
u = get_user_by_id(uid) if uid is not None else None
if perm is None and uid is not None:
@@ -26,9 +24,11 @@ def home(request):
perm = int(perm)
except Exception:
perm = 1
has_manage_key = bool((u or {}).get("manage_key") or [])
context = {
"user_id": uid,
"username": (u or {}).get("username"),
"is_admin": (int(perm) == 0),
"has_manage_key": has_manage_key,
}
return render(request, "main/home.html", context)