正在显示
11 个修改的文件
包含
65 行增加
和
16 行删除
@@ -7,9 +7,6 @@ from rest_framework.generics import CreateAPIView, RetrieveAPIView, UpdateAPIVie | @@ -7,9 +7,6 @@ from rest_framework.generics import CreateAPIView, RetrieveAPIView, UpdateAPIVie | ||
7 | from rest_framework.permissions import IsAuthenticated, IsAdminUser | 7 | from rest_framework.permissions import IsAuthenticated, IsAdminUser |
8 | from rest_framework.exceptions import ValidationError | 8 | from rest_framework.exceptions import ValidationError |
9 | from rest_framework.views import APIView | 9 | from rest_framework.views import APIView |
10 | -from rest_framework.response import Response | ||
11 | -from django.contrib.auth.decorators import login_required | ||
12 | -from django.views.decorators.http import require_http_methods | ||
13 | 10 | ||
14 | from .serializers import ProjectSerializer | 11 | from .serializers import ProjectSerializer |
15 | from .models import Auditor, Project, Result | 12 | from .models import Auditor, Project, Result |
@@ -17,11 +14,7 @@ from utils.helpers import WxPushHelper | @@ -17,11 +14,7 @@ from utils.helpers import WxPushHelper | ||
17 | from utils.pagination import MyPageNumberPagination | 14 | from utils.pagination import MyPageNumberPagination |
18 | from utils.util import response | 15 | from utils.util import response |
19 | from wxProject.settings import FRONT_URL | 16 | from wxProject.settings import FRONT_URL |
20 | - | ||
21 | -AUDITORS = ( | ||
22 | - (1, '邓望明'), | ||
23 | - (2, '杜波') | ||
24 | -) | 17 | +from wxProject.qywx_settings import Conf, project_conf |
25 | 18 | ||
26 | 19 | ||
27 | class CreateProject(CreateAPIView): | 20 | class CreateProject(CreateAPIView): |
@@ -30,7 +23,7 @@ class CreateProject(CreateAPIView): | @@ -30,7 +23,7 @@ class CreateProject(CreateAPIView): | ||
30 | 23 | ||
31 | def post(self, request, *args, **kwargs): | 24 | def post(self, request, *args, **kwargs): |
32 | super(CreateProject, self).__init__() | 25 | super(CreateProject, self).__init__() |
33 | - wx_client = WxPushHelper() | 26 | + wx_client = WxPushHelper(Conf[project_conf['APP_ID']]) |
34 | serializer = ProjectSerializer(data=request.data) | 27 | serializer = ProjectSerializer(data=request.data) |
35 | if not serializer.is_valid(): | 28 | if not serializer.is_valid(): |
36 | raise ValidationError(serializer.errors) | 29 | raise ValidationError(serializer.errors) |
@@ -106,7 +99,7 @@ class AuditProject(UpdateAPIView): | @@ -106,7 +99,7 @@ class AuditProject(UpdateAPIView): | ||
106 | result.memo = request.data.get('memo', '') | 99 | result.memo = request.data.get('memo', '') |
107 | result.save() | 100 | result.save() |
108 | 101 | ||
109 | - wx_client = WxPushHelper() | 102 | + wx_client = WxPushHelper(Conf[project_conf['APP_ID']]) |
110 | full_audit_done = self._check_audit(obj) | 103 | full_audit_done = self._check_audit(obj) |
111 | url = re.sub("PK", str(obj.id), FRONT_URL['flow_detail']) | 104 | url = re.sub("PK", str(obj.id), FRONT_URL['flow_detail']) |
112 | url = re.sub("REDIRECT_URL", parse.quote(url, safe=''), FRONT_URL['wx_authorize']) | 105 | url = re.sub("REDIRECT_URL", parse.quote(url, safe=''), FRONT_URL['wx_authorize']) |
@@ -8,10 +8,17 @@ django-filter==2.4.0 | @@ -8,10 +8,17 @@ django-filter==2.4.0 | ||
8 | djangorestframework==3.12.1 | 8 | djangorestframework==3.12.1 |
9 | djangorestframework-simplejwt==4.4.0 | 9 | djangorestframework-simplejwt==4.4.0 |
10 | idna==2.10 | 10 | idna==2.10 |
11 | +lml==0.1.0 | ||
11 | mysqlclient==2.0.1 | 12 | mysqlclient==2.0.1 |
12 | Pillow==7.2.0 | 13 | Pillow==7.2.0 |
14 | +pyexcel==0.6.5 | ||
15 | +pyexcel-io==0.6.4 | ||
16 | +pyexcel-xls==0.6.1 | ||
13 | PyJWT==1.7.1 | 17 | PyJWT==1.7.1 |
14 | pytz==2020.1 | 18 | pytz==2020.1 |
15 | requests==2.24.0 | 19 | requests==2.24.0 |
16 | sqlparse==0.3.1 | 20 | sqlparse==0.3.1 |
21 | +texttable==1.6.3 | ||
17 | urllib3==1.25.10 | 22 | urllib3==1.25.10 |
23 | +xlrd==1.2.0 | ||
24 | +xlwt==1.3.0 |
sku/__init__.py
0 → 100644
sku/admin.py
0 → 100644
sku/apps.py
0 → 100644
sku/migrations/__init__.py
0 → 100644
sku/models.py
0 → 100644
sku/tests.py
0 → 100644
sku/views.py
0 → 100644
@@ -12,6 +12,7 @@ from libs.qywx.conf import Conf | @@ -12,6 +12,7 @@ from libs.qywx.conf import Conf | ||
12 | from libs.qywx.CorpApi import CorpApi, CORP_API_TYPE | 12 | from libs.qywx.CorpApi import CorpApi, CORP_API_TYPE |
13 | from usercenter.models import UserManager, User | 13 | from usercenter.models import UserManager, User |
14 | from utils.util import response | 14 | from utils.util import response |
15 | +from wxProject.qywx_settings import Conf | ||
15 | 16 | ||
16 | 17 | ||
17 | class WxRequiredMixin(View): | 18 | class WxRequiredMixin(View): |
@@ -27,9 +28,13 @@ class WxRequiredMixin(View): | @@ -27,9 +28,13 @@ class WxRequiredMixin(View): | ||
27 | 28 | ||
28 | class WxPushHelper: | 29 | class WxPushHelper: |
29 | api = None | 30 | api = None |
31 | + conf = None | ||
30 | 32 | ||
31 | - def __init__(self): | ||
32 | - self.api = CorpApi(Conf['CORP_ID'], Conf['APP_SECRET']) | 33 | + def __init__(self, conf): |
34 | + if not conf: | ||
35 | + raise ValueError("企业微信配置有误,配置项不能为空") | ||
36 | + self.conf = conf | ||
37 | + self.api = CorpApi(self.conf['CORP_ID'], self.conf['APP_SECRET']) | ||
33 | 38 | ||
34 | def get_corp_user_id_by_code(self, code): | 39 | def get_corp_user_id_by_code(self, code): |
35 | return self.api.httpCall(CORP_API_TYPE['GET_USER_INFO_BY_CODE'], {"CODE": code}) | 40 | return self.api.httpCall(CORP_API_TYPE['GET_USER_INFO_BY_CODE'], {"CODE": code}) |
@@ -39,7 +44,7 @@ class WxPushHelper: | @@ -39,7 +44,7 @@ class WxPushHelper: | ||
39 | 44 | ||
40 | def push_text(self, user_wx_id, content): | 45 | def push_text(self, user_wx_id, content): |
41 | data = { | 46 | data = { |
42 | - "agentid": Conf['APP_ID'], # 企业应用ID | 47 | + "agentid": self.conf['APP_ID'], # 企业应用ID |
43 | "msgtype": 'text', # 消息类型为文本 | 48 | "msgtype": 'text', # 消息类型为文本 |
44 | "touser": user_wx_id, # 接受消息的对象 | 49 | "touser": user_wx_id, # 接受消息的对象 |
45 | "text": { | 50 | "text": { |
@@ -52,7 +57,7 @@ class WxPushHelper: | @@ -52,7 +57,7 @@ class WxPushHelper: | ||
52 | data = { | 57 | data = { |
53 | "touser": str(user_wx_id), | 58 | "touser": str(user_wx_id), |
54 | "msgtype": "textcard", | 59 | "msgtype": "textcard", |
55 | - "agentid": Conf['APP_ID'], # 企业应用ID | 60 | + "agentid": self.conf['APP_ID'], # 企业应用ID |
56 | "textcard": { | 61 | "textcard": { |
57 | "title": "产品立项流程通知", | 62 | "title": "产品立项流程通知", |
58 | "description": description, | 63 | "description": description, |
@@ -72,8 +77,8 @@ class WxUserlogin(APIView): | @@ -72,8 +77,8 @@ class WxUserlogin(APIView): | ||
72 | permission_classes = (AllowAny, ) | 77 | permission_classes = (AllowAny, ) |
73 | 78 | ||
74 | @staticmethod | 79 | @staticmethod |
75 | - def _get_user_info(code): | ||
76 | - client = WxPushHelper() | 80 | + def _get_user_info(code, app_id): |
81 | + client = WxPushHelper(Conf[app_id]) | ||
77 | corp_user = client.get_corp_user_id_by_code(code) | 82 | corp_user = client.get_corp_user_id_by_code(code) |
78 | if "errcode" in corp_user and corp_user['errcode'] == 0 and "UserId" in corp_user: | 83 | if "errcode" in corp_user and corp_user['errcode'] == 0 and "UserId" in corp_user: |
79 | return client.get_user_info_by_corp_user_id(corp_user['UserId']) | 84 | return client.get_user_info_by_corp_user_id(corp_user['UserId']) |
wxProject/qywx_settings.py
0 → 100644
1 | +# _*_ coding: utf-8 _*_ | ||
2 | +# @Time : 2020/11/2 18:01 | ||
3 | +# @Author vanwhebin | ||
4 | +from wxProject.settings import DEBUG | ||
5 | + | ||
6 | +DEBUG = DEBUG | ||
7 | + | ||
8 | +# 企业微信的一些配置项 | ||
9 | +project_conf = { | ||
10 | + "title": "产品立项", | ||
11 | + "CORP_ID": "ww0f3efc2873ad11c3", | ||
12 | + "APP_ID": '1000078', | ||
13 | + "APP_SECRET": "7MHpdQICiegx9rIc4iZrEPunb1aYUqdJYKSW9v7a1A8", | ||
14 | + } | ||
15 | + | ||
16 | +sku_conf = { | ||
17 | + "title": "sku条目审批应用", | ||
18 | + "CORP_ID": "ww0f3efc2873ad11c3", | ||
19 | + "APP_ID": '1000081', | ||
20 | + "APP_SECRET": "_O_MrxbQO1vojzNBPAiaF_MdzikHRbnVfFc3v8iOtKo", | ||
21 | + } | ||
22 | + | ||
23 | + | ||
24 | +Conf = { | ||
25 | + "1000078": project_conf, | ||
26 | + "1000081": sku_conf | ||
27 | +} |
-
请 注册 或 登录 后发表评论