Commit 821b6fb8a0cc384f4a5bd757d6c79565cce7296f

Authored by zhenchaozhu
1 parent f96567709e
Exists in master

remove pyqccr

Showing 1 changed file with 3 additions and 8 deletions   Show diff stats
... ... @@ -4,8 +4,6 @@ import django.http
4 4 from functools import wraps
5 5 from django.conf import settings
6 6 from django.utils.decorators import available_attrs
7   -from pyqccr.http.response_code import REQUEST_FORBIDDEN
8   -from pyqccr.http.status import HTTP_403_FORBIDDEN
9 7 from django.shortcuts import resolve_url
10 8 from django.utils.six.moves.urllib.parse import urlparse
11 9  
... ... @@ -50,15 +48,12 @@ import json
50 48  
51 49 from django.http import JsonResponse
52 50  
53   -from pyqccr.http.response_code import REQUEST_SUCCESS, REQUEST_FAILURE_UNIVERSAL
54   -from pyqccr.http.status import HTTP_200_OK, HTTP_400_BAD_REQUEST
55   -
56 51  
57 52 class QCCRJsonResponse(JsonResponse):
58 53 """
59 54 封装了返回码和信息的JsonResponse类
60 55 """
61   - def __init__(self, obj=None, code=REQUEST_SUCCESS, msg="success", status=HTTP_200_OK, **kwargs):
  56 + def __init__(self, obj=None, code=200, msg="success", status=200, **kwargs):
62 57 data = {"code": code, "msg": msg, "result": json.loads(obj) if isinstance(obj, (str, unicode)) else obj}
63 58 super(QCCRJsonResponse, self).__init__(data=data, status=status, **kwargs)
64 59  
... ... @@ -67,7 +62,7 @@ class QCCRErrorResponse(QCCRJsonResponse):
67 62 """
68 63 请求错误
69 64 """
70   - def __init__(self, obj=None, code=REQUEST_FAILURE_UNIVERSAL, msg="failure", status=HTTP_400_BAD_REQUEST, **kwargs):
  65 + def __init__(self, obj=None, code=400, msg="failure", status=400, **kwargs):
71 66 super(QCCRErrorResponse, self).__init__(obj=obj, code=code, msg=msg, status=status, **kwargs)
72 67  
73 68 def user_passes_test(test_func, login_url=None,
... ... @@ -83,7 +78,7 @@ def user_passes_test(test_func, login_url=None,
83 78 return view_func(request, *args, **kwargs)
84 79 # 如果未通过检查,且为ajax请求,返回403
85 80 if request.is_ajax():
86   - return QCCRErrorResponse(code=REQUEST_FORBIDDEN, msg="用户身份检查失败", status=HTTP_403_FORBIDDEN)
  81 + return QCCRErrorResponse(code=403, msg="用户身份检查失败", status=403)
87 82 # 非ajax请求,跳转到登录页面
88 83 path = request.build_absolute_uri()
89 84 resolved_login_url = resolve_url(login_url or getattr(settings, "QCCR_LOGIN_URL", '/login/'))
... ...