实现根据用户登录状态的来确定首页页面跳转问题
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -116,8 +116,6 @@
|
||||
loopBottom: true
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user