Merge remote-tracking branch 'origin/Django' into Django

This commit is contained in:
DSQ
2025-11-15 21:47:58 +08:00
7 changed files with 64 additions and 149 deletions

View File

@@ -16,10 +16,18 @@ def home(request):
perm = request.session.get("permission")
if perm is None and uid is not None:
u = get_user_by_id(uid)
perm = (u or {}).get("permission", 1)
try:
perm = int((u or {}).get("permission", 1))
except Exception:
perm = 1
request.session["permission"] = perm
else:
try:
perm = int(perm)
except Exception:
perm = 1
context = {
"user_id": uid,
"is_admin": (perm == 0),
"is_admin": (int(perm) == 0),
}
return render(request, "main/home.html", context)