diff --git a/accounts/templates/accounts/class_info.html b/accounts/templates/accounts/class_info.html deleted file mode 100644 index 6e1f219..0000000 --- a/accounts/templates/accounts/class_info.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - 填写班级信息 - - - -
-

完善班级信息

-
- {% csrf_token %} - - - -
格式要求:XXXX级YY专业Z班(记得加“专业”两个字)
- -
-
-
- - - diff --git a/accounts/urls.py b/accounts/urls.py index 35ad07a..453a596 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -12,7 +12,5 @@ urlpatterns = [ path("register/", views.register_page, name="register"), path("register/submit/", views.register_submit, name="register_submit"), path("email/send-code/", views.send_email_code, name="send_email_code"), - path("class-info/", views.class_info_page, name="class_info"), - path("class-info/submit/", views.class_info_submit, name="class_info_submit"), path("profile/", views.profile_page, name="profile"), ] \ No newline at end of file diff --git a/accounts/views.py b/accounts/views.py index aadb13e..555d843 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -272,43 +272,7 @@ def register_submit(request): del request.session["email_verify"] except Exception: pass - # 修改:注册成功后跳转到完善班级信息页面 - return JsonResponse({"ok": True, "redirect_url": f"/accounts/class-info/?user_id={next_id}"}) - -@require_http_methods(["GET"]) -@ensure_csrf_cookie -def class_info_page(request): - user_id = request.GET.get("user_id") - if not user_id: - return redirect("/accounts/register/") - return render(request, "accounts/class_info.html", {"user_id": user_id}) - -@require_http_methods(["POST"]) -@csrf_protect -def class_info_submit(request): - try: - payload = json.loads(request.body.decode("utf-8")) - except json.JSONDecodeError: - return HttpResponseBadRequest("Invalid JSON") - - user_id = payload.get("user_id") - class_name = (payload.get("class_name") or "").strip() - - if not user_id or not class_name: - return HttpResponseBadRequest("Missing fields") - - # 后端校验:2024级**专业*班 - import re - pattern = r"^\d{4}级.+专业\d+班$" - if not re.match(pattern, class_name): - return JsonResponse({"ok": False, "message": "班级格式不正确"}, status=400) - - # 更新用户信息,将班级信息存入 key 列表 - ok = update_user_by_id(user_id, key=[class_name]) - if not ok: - return JsonResponse({"ok": False, "message": "保存班级信息失败"}, status=500) - - return JsonResponse({"ok": True}) + return JsonResponse({"ok": True, "redirect_url": "/accounts/login/"}) @require_http_methods(["POST"]) @csrf_protect diff --git a/elastic/templates/elastic/manage.html b/elastic/templates/elastic/manage.html index 33b5d16..3ceb9e1 100644 --- a/elastic/templates/elastic/manage.html +++ b/elastic/templates/elastic/manage.html @@ -16,6 +16,9 @@ table{width:100%;border-collapse:collapse;margin-top:20px} th,td{border-bottom:1px solid #eee;padding:12px 8px;text-align:left;vertical-align:top} th{background:#f8f9fa;font-weight:600} + .inner-table { width: 100%; margin: 0; border: 1px solid #e0e0e0; border-collapse: collapse; } + .inner-table th, .inner-table td { border: 1px solid #e0e0e0; padding: 6px; font-size: 12px; } + .inner-table th { background-color: #f9f9f9; } img{max-width:120px;border:1px solid #eee;border-radius:6px;cursor:pointer} .btn{padding:6px 10px;border:none;border-radius:6px;cursor:pointer;font-size:14px;margin:2px} .btn-primary{background:#1677ff;color:#fff} @@ -86,7 +89,6 @@ - @@ -320,18 +322,28 @@ function renderTable(data) { let displayData = item.data || ''; try { const parsed = JSON.parse(item.data); - displayData = JSON.stringify(parsed, null, 2); + displayData = ` +
ID 图片 数据 录入人
+ + ${Object.entries(parsed).map(([key, value]) => ` + + + + + `).join('')} + +
${escapeHtml(key)}${escapeHtml(typeof value === 'object' ? JSON.stringify(value, null, 2) : value)}
+ `; } catch (e) { - // 如果不是JSON,直接显示原字符串 + displayData = `
${escapeHtml(displayData)}
`; } row.innerHTML = ` - ${item._id || item.id || ''}
${buildImageCell(item)}
-
${escapeHtml(displayData)}
+ ${displayData} ${item.writer_name || item.writer_id || ''}