作者 wanweibin

update

@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 # @Time : 2020/10/7 10:40 2 # @Time : 2020/10/7 10:40
3 # @Author vanwhebin 3 # @Author vanwhebin
4 import re 4 import re
  5 +from urllib import parse
5 from rest_framework.generics import CreateAPIView, RetrieveAPIView, UpdateAPIView, ListAPIView 6 from rest_framework.generics import CreateAPIView, RetrieveAPIView, UpdateAPIView, ListAPIView
6 from rest_framework.permissions import IsAuthenticated, IsAdminUser 7 from rest_framework.permissions import IsAuthenticated, IsAdminUser
7 from rest_framework.exceptions import ValidationError 8 from rest_framework.exceptions import ValidationError
@@ -39,6 +40,7 @@ class CreateProject(CreateAPIView): @@ -39,6 +40,7 @@ class CreateProject(CreateAPIView):
39 # 企业微信推送 40 # 企业微信推送
40 obj_dict = serializer.data 41 obj_dict = serializer.data
41 url = re.sub("PK", str(obj_dict['id']), FRONT_URL['flow_detail']) 42 url = re.sub("PK", str(obj_dict['id']), FRONT_URL['flow_detail'])
  43 + url = re.sub("REDIRECT_URL", parse.quote(url, safe=''), FRONT_URL['wx_authorize'])
42 first_auditor = User.objects.filter(pk=AUDITORS[0][0]).first() 44 first_auditor = User.objects.filter(pk=AUDITORS[0][0]).first()
43 wx_client.push_card(first_auditor.wx_token, url, f"{request.user.username}提交了一个产品立项申请") 45 wx_client.push_card(first_auditor.wx_token, url, f"{request.user.username}提交了一个产品立项申请")
44 wx_client.push_card(request.user.wx_token, url, u"流程创建成功") 46 wx_client.push_card(request.user.wx_token, url, u"流程创建成功")
@@ -96,6 +98,7 @@ class AuditProject(UpdateAPIView): @@ -96,6 +98,7 @@ class AuditProject(UpdateAPIView):
96 wx_client = WxPushHelper() 98 wx_client = WxPushHelper()
97 full_audit_done = self._check_audit(obj) 99 full_audit_done = self._check_audit(obj)
98 url = re.sub("PK", str(obj.id), FRONT_URL['flow_detail']) 100 url = re.sub("PK", str(obj.id), FRONT_URL['flow_detail'])
  101 + url = re.sub("REDIRECT_URL", parse.quote(url, safe=''), FRONT_URL['wx_authorize'])
99 desc = "产品立项流程所有审批已完成" if full_audit_done else f"{request.user.username}已审批完成" 102 desc = "产品立项流程所有审批已完成" if full_audit_done else f"{request.user.username}已审批完成"
100 if full_audit_done: 103 if full_audit_done:
101 obj.is_done = True 104 obj.is_done = True
@@ -98,6 +98,6 @@ class WxUserlogin(APIView): @@ -98,6 +98,6 @@ class WxUserlogin(APIView):
98 user.save() 98 user.save()
99 # 获取token 99 # 获取token
100 token_obj = TokenObtainPairSerializer.get_token(user) 100 token_obj = TokenObtainPairSerializer.get_token(user)
101 - return response({"access_token": str(token_obj.access_token)}) 101 + return response({"access_token": str(token_obj.access_token), 'fresh_token': token_obj.fresh_token})
102 102
103 103
@@ -177,5 +177,6 @@ SIMPLE_JWT = { @@ -177,5 +177,6 @@ SIMPLE_JWT = {
177 } 177 }
178 178
179 FRONT_URL = { 179 FRONT_URL = {
  180 + "wx_authorize": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww0f3efc2873ad11c3&redirect_uri=REDIRECT_URL&response_type=code&scope=snsapi_base#wechat_redirect",
180 "flow_detail": "http://project.tacklifetools.com/product/audit/PK" 181 "flow_detail": "http://project.tacklifetools.com/product/audit/PK"
181 } 182 }