Merge branch 'hohoTT-dev' into virusdefender-dev
* hohoTT-dev: 实现根据用户登录状态的来确定首页页面跳转问题 首页增加登录选项,之后实现页面之间的跳转问题
This commit is contained in:
@@ -36,11 +36,24 @@ class UserLoginAPIView(APIView):
|
|||||||
else:
|
else:
|
||||||
return serializer_invalid_response(serializer)
|
return serializer_invalid_response(serializer)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def logout(request):
|
def logout(request):
|
||||||
auth.logout(request)
|
auth.logout(request)
|
||||||
return http.HttpResponseRedirect("/")
|
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):
|
class UserRegisterAPIView(APIView):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ from contest_submission.views import contest_problem_my_submissions_list_page
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^install/$', "install.views.install"),
|
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'^docs/', include('rest_framework_swagger.urls')),
|
||||||
url(r'^admin/$', TemplateView.as_view(template_name="admin/admin.html"), name="admin_spa_page"),
|
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"),
|
url(r'^admin/contest/$', TemplateView.as_view(template_name="admin/contest/add_contest.html"),
|
||||||
|
|||||||
@@ -29,6 +29,36 @@
|
|||||||
padding: 20px 20px 0 20px;
|
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 {
|
#name {
|
||||||
font-size: 45px;
|
font-size: 45px;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
@@ -86,8 +116,6 @@
|
|||||||
loopBottom: true
|
loopBottom: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
@@ -100,6 +128,12 @@
|
|||||||
<a href="/groups/">小组</a>
|
<a href="/groups/">小组</a>
|
||||||
<a href="/about/">关于</a>
|
<a href="/about/">关于</a>
|
||||||
|
|
||||||
|
{% if not request.user.is_authenticated %}
|
||||||
|
<div id="login">
|
||||||
|
<a href="/login/" class="login button">登录</a>
|
||||||
|
<a href="/register/" class="register button">注册</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user