Skip to content

Commit

Permalink
Merge pull request #1092 from longguikeji/feature-555
Browse files Browse the repository at this point in the history
fix: 🐛 修复审批请求403报错提示
  • Loading branch information
fanhe-lg committed Jul 29, 2022
2 parents 864d49e + e91718c commit 4647042
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions arkid/core/approve_request_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
from django.urls import resolve
from arkid.core.models import Tenant
from django.http import HttpResponse
from django.http import HttpResponse, JsonResponse
from arkid.core.models import ApproveAction, ApproveRequest
from arkid.core.approve import create_approve_request
from arkid.common.utils import verify_token
Expand All @@ -16,6 +16,8 @@
dispatch_event,
CREATE_APPROVE_REQUEST,
)
from arkid.core.translation import gettext_default as _
from arkid.core.error import ErrorCode, ErrorDict


class ApproveRequestMiddleware:
Expand Down Expand Up @@ -67,11 +69,17 @@ def process_view(self, request, view_func, view_args, view_kwargs):
data=approve_request,
)
)
response = HttpResponse(status=403)
response = JsonResponse(
ErrorDict(ErrorCode.APPROVE_REQUEST_WAITING),
status=403,
)
return response
else:
if approve_request.status != "pass":
response = HttpResponse(status=403)
response = JsonResponse(
ErrorDict(ErrorCode.APPROVE_REQUEST_WAITING),
status=403,
)
return response
else:
return None
Expand Down
1 change: 1 addition & 0 deletions arkid/core/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ErrorCode(Enum):

APPROVE_ACTION_DUPLICATED = ('14001', _('approve action duplicated', '审批动作重复'))
APPROVE_ACTION_NOT_EXISTS = ('14002', _('approve action not exists', '审批动作不存在'))
APPROVE_REQUEST_WAITING = ('14003', _('approve request created, please wait', '审批请求已创建,等待审批'))

WEBHOOK_NOT_EXISTS = ('15001', _('webhook not exists', '回调动作不存在'))
WEBHOOK_HISTORY_NOT_EXISTS = ('15002', _('webhook history not exists', '回调动作历史不存在'))
Expand Down

0 comments on commit 4647042

Please sign in to comment.