From 530b45b39c72a457c53b746756e7504cf243b73c Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Sun, 13 Sep 2015 19:39:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=80=89=E9=A1=B9=EF=BC=8C=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E9=A1=B5=E9=9D=A2=E4=B9=8B=E9=97=B4=E7=9A=84?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/src/oj/index.html | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/template/src/oj/index.html b/template/src/oj/index.html index c8c1d8f..ee93725 100644 --- a/template/src/oj/index.html +++ b/template/src/oj/index.html @@ -29,6 +29,36 @@ padding: 20px 20px 0 20px; } + #login { + float: right; + position: relative; + height: 30px; + line-height: 64px; + margin-right: 30px; + z-index: 10; + margin-top: 4px; + } + + .login-zone .button:first-child { + margin-right: 5px; + } + + .button { + display: inline-block; + padding: 0 2em; + text-transform: none; + line-height: 2em; + height: 2em; + border-radius: 2em; + border: 1px solid #FFF; + outline: 0; + cursor: pointer; + } + + .button:first-child { + margin-right: 5px; + } + #name { font-size: 45px; margin-right: 20px; @@ -100,6 +130,12 @@ 小组   关于 + {% if not request.user.is_authenticated %} +
+ 登录 + 注册 +
+ {% endif %} From fcb0a3b2a66cd14da9af7b537163850009e87d36 Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Sun, 13 Sep 2015 21:58:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95=E7=8A=B6=E6=80=81=E7=9A=84?= =?UTF-8?q?=E6=9D=A5=E7=A1=AE=E5=AE=9A=E9=A6=96=E9=A1=B5=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account/views.py | 13 +++++++++++++ oj/urls.py | 2 +- template/src/oj/index.html | 2 -- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/account/views.py b/account/views.py index 1304ded..4aa326a 100644 --- a/account/views.py +++ b/account/views.py @@ -36,11 +36,24 @@ class UserLoginAPIView(APIView): else: return serializer_invalid_response(serializer) + @login_required def logout(request): auth.logout(request) return http.HttpResponseRedirect("/") + +def page_jump(request): + if not request.user.is_authenticated(): + return render(request, "oj/index.html") + + try: + if request.META['HTTP_REFERER']: + return render(request, "oj/index.html") + except KeyError: + return http.HttpResponseRedirect('/problems/') + + class UserRegisterAPIView(APIView): def post(self, request): """ diff --git a/oj/urls.py b/oj/urls.py index e9cc880..eda20bb 100644 --- a/oj/urls.py +++ b/oj/urls.py @@ -26,7 +26,7 @@ from contest_submission.views import contest_problem_my_submissions_list_page urlpatterns = [ url(r'^install/$', "install.views.install"), - url("^$", TemplateView.as_view(template_name="oj/index.html"), name="index_page"), + url("^$", "account.views.page_jump", name="page_jump_api"), url(r'^docs/', include('rest_framework_swagger.urls')), url(r'^admin/$', TemplateView.as_view(template_name="admin/admin.html"), name="admin_spa_page"), url(r'^admin/contest/$', TemplateView.as_view(template_name="admin/contest/add_contest.html"), diff --git a/template/src/oj/index.html b/template/src/oj/index.html index ee93725..8244f86 100644 --- a/template/src/oj/index.html +++ b/template/src/oj/index.html @@ -116,8 +116,6 @@ loopBottom: true }); }); - -