没有登录的时候自动跳转到登录页面,修改相关测试

This commit is contained in:
virusdefender
2015-08-23 20:45:02 +08:00
parent b590ee8577
commit f682aa1fb3
4 changed files with 10 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
# coding=utf-8
from functools import wraps
from django.http import HttpResponse
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from utils.shortcuts import error_response, error_page
@@ -18,7 +18,7 @@ def login_required(func):
if request.is_ajax():
return error_response(u"请先登录")
else:
return error_page(request, u"请先登录")
return HttpResponseRedirect("/login/")
return check
@@ -31,5 +31,5 @@ def admin_required(func):
if request.is_ajax():
return error_response(u"需要管理员权限")
else:
return error_page(request, u"需要管理员权限")
return error_page(request, u"需要管理员权限,如果没有登录,请先登录")
return check