...
|
...
|
@@ -35,17 +35,18 @@ class CreateProject(CreateAPIView): |
|
|
if not serializer.is_valid():
|
|
|
raise ValidationError(serializer.errors)
|
|
|
else:
|
|
|
serializer.save(creator=request.user, auditor=Auditor.objects.order_by('-order').all())
|
|
|
# 企业微信推送
|
|
|
obj_dict = serializer.data
|
|
|
for i in AUDITORS:
|
|
|
auditors = Auditor.objects.filter(type=obj_dict['type']).order_by('order')
|
|
|
serializer.save(creator=request.user, auditor=auditors)
|
|
|
# 企业微信推送
|
|
|
for i in auditors:
|
|
|
Result.objects.create(
|
|
|
auditor_id=i[0],
|
|
|
auditor_id=i.pk,
|
|
|
project_id=obj_dict['id']
|
|
|
)
|
|
|
url = re.sub("PK", str(obj_dict['id']), FRONT_URL['flow_detail'])
|
|
|
url = re.sub("REDIRECT_URL", parse.quote(url, safe=''), FRONT_URL['wx_authorize'])
|
|
|
first_auditor = Auditor.objects.filter(pk=AUDITORS[0][0]).first()
|
|
|
first_auditor = auditors[0]
|
|
|
|
|
|
wx_client.push_card(first_auditor.user.wx_token, url, f"{request.user.username}提交了一个产品立项申请")
|
|
|
wx_client.push_card(request.user.wx_token, url, u"流程创建成功")
|
...
|
...
|
@@ -61,8 +62,7 @@ class ProjectDetail(RetrieveAPIView): |
|
|
obj = self.get_object()
|
|
|
obj.creator_name = obj.creator.username
|
|
|
obj.result = []
|
|
|
auditors = Auditor.objects.all()
|
|
|
# result = Result.objects.filter(project=obj)
|
|
|
auditors = Auditor.objects.filter(type=obj.type)
|
|
|
for i in auditors:
|
|
|
res = i.result_auditor.filter(project=obj).values('is_accept', 'memo').first()
|
|
|
obj.result.append({
|
...
|
...
|
@@ -94,12 +94,14 @@ class AuditProject(UpdateAPIView): |
|
|
('reject', '否决')
|
|
|
)
|
|
|
accept_param = accept_choices[0][0] if request.data.get('is_accept') else accept_choices[1][0]
|
|
|
target = Project.objects.filter(auditor__user_id=request.user.id, pk=obj.id)
|
|
|
if not target:
|
|
|
# target = Project.objects.filter(auditor__user_id=request.user.id, pk=obj.id)
|
|
|
if not obj:
|
|
|
raise PermissionError
|
|
|
else:
|
|
|
auditor = Auditor.objects.get(user=request.user)
|
|
|
result = Result.objects.filter(auditor=auditor, project=obj).first()
|
|
|
result = Result.objects.filter(auditor=auditor, project=obj, is_accept__isnull=True).order_by('pk').first()
|
|
|
if not result:
|
|
|
raise PermissionError("不允许修改已审核的项目")
|
|
|
result.is_accept = accept_param
|
|
|
result.memo = request.data.get('memo', '')
|
|
|
result.save()
|
...
|
...
|
@@ -117,7 +119,9 @@ class AuditProject(UpdateAPIView): |
|
|
obj.is_done = True
|
|
|
obj.is_pass = False
|
|
|
else:
|
|
|
second_auditor = Auditor.objects.filter(pk=AUDITORS[1][0]).first()
|
|
|
next_auditor_id = Result.objects.filter(project=obj, is_accept__isnull=True)\
|
|
|
.values_list('auditor_id', flat=True).order_by('pk').first()
|
|
|
second_auditor = Auditor.objects.filter(pk=next_auditor_id).first()
|
|
|
wx_client.push_card(second_auditor.user.wx_token, url, f"{request.user.username}已审核了一个产品立项申请")
|
|
|
obj.save()
|
|
|
wx_client.push_card(obj.creator.wx_token, url, desc)
|
...
|
...
|
|