默认审批系统插件#
功能介绍#
默认审批系统插件安装后,会在审批管理菜单下面添加默认请求处理页面,用于处理分配给当前审批系统的审批请求
创建审批动作#
生成审批请求#
查看审批请求#
处理审批请求#
实现思路#
- 在approve_requests_page中添加默认请求处理页面
- 默认请求处理 页面中调用 /approve_requests/{{request_id}}/pass/ 同意审批请求
- 默认请求处理 页面中调用 /approve_requests/{{request_id}}/deny/ 拒绝审批请求
- 实现 pass_approve_request 抽象方法 同意审批请求
- 实现 deny_approve_request 抽象方法 拒绝审批请求
- 由于此插件只不需要将审批请求发送到第三方所以没有覆盖抽象方法create_approve_request
- 插件基类见arkid.core.extension.approve_system.ApproveSystemExtension
抽象方法实现:#
代码#
extension_root.com_longgui_approve_system_arkid.ApproveSystemArkIDExtension (ApproveSystemExtension)
#
Source code in extension_root/com_longgui_approve_system_arkid/__init__.py
class ApproveSystemArkIDExtension(ApproveSystemExtension):
def load(self):
super().load()
self.register_api(
f'/approve_requests/',
'GET',
self.list_tenant_approve_requests,
response=List[ApproveRequestListItemOut],
tenant_path=True,
)
self.register_approve_system_schema(
ApproveSystemArkIDConfigSchema, 'approve_system_arkid'
)
self.register_front_pages([router_page, waiting_page, approved_page])
self.register_front_routers(router, approve_manage_router)
@operation(List[ApproveRequestListItemOut], roles=[TENANT_ADMIN, PLATFORM_ADMIN])
@paginate(CustomPagination)
def list_tenant_approve_requests(
self, request, tenant_id: str, is_approved: str = ''
):
package = 'com.longgui.approve.system.arkid'
requests = ApproveRequest.valid_objects.filter(
tenant=request.tenant, action__extension__package=package
)
if is_approved == 'true':
requests = requests.exclude(status="wait")
elif is_approved == 'false':
requests = requests.filter(status="wait")
return requests
def create_approve_request(self, event, **kwargs):
pass
def pass_approve_request(self, request, approve_request):
response = restore_approve_request(approve_request)
logger.info(f'Restore approve request with result: {response}')
def deny_approve_request(self, request, approve_request):
pass
create_approve_request(self, event, **kwargs)
#
deny_approve_request(self, request, approve_request)
#
抽象方法
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
django.http.HttpRequest |
HTTP 请求 |
required |
approve_request |
arkid.core.models.ApproveRequest |
需要拒绝的审批请求 |
required |
load(self)
#
抽象方法,插件加载的入口方法
Source code in extension_root/com_longgui_approve_system_arkid/__init__.py
def load(self):
super().load()
self.register_api(
f'/approve_requests/',
'GET',
self.list_tenant_approve_requests,
response=List[ApproveRequestListItemOut],
tenant_path=True,
)
self.register_approve_system_schema(
ApproveSystemArkIDConfigSchema, 'approve_system_arkid'
)
self.register_front_pages([router_page, waiting_page, approved_page])
self.register_front_routers(router, approve_manage_router)
pass_approve_request(self, request, approve_request)
#
抽象方法
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
django.http.HttpRequest |
HTTP 请求 |
required |
approve_request |
arkid.core.models.ApproveRequest |
需要同意的审批请求 |
required |