Explorar el Código

Merge branch '1.1.3-guoyq' into 1.1.3-master

‘suhuihui’ hace 2 meses
padre
commit
70816647e9
Se han modificado 1 ficheros con 31 adiciones y 10 borrados
  1. 31 10
      api/controllers/console/datasets/datasets_document.py

+ 31 - 10
api/controllers/console/datasets/datasets_document.py

@@ -856,11 +856,24 @@ class DocumentStatusApi(DocumentResource):
             if action == "enable":
                 if document.enabled:
                     continue
-                if current_user.current_role not in (TenantAccountRole.ADMIN, TenantAccountRole.OWNER):
-                    document.enable_applicant = current_user.id
-                    document.check_status = 1
-                    db.session.commit()
-                    return {"result": "该操作需要提交管理员审核后生效,请确认是否提交"}, 200
+                #     本人 本人
+                if dataset.edit_auth == 1:
+                    if current_user != dataset.created_by:
+                        document.enable_applicant = current_user.id
+                        document.check_status = 1
+                        db.session.commit()
+                        return {"result": "该操作需要提交所有者审核后生效,请确认是否提交"}, 200
+                #     本部门
+                if dataset.edit_auth == 2:
+                    # 非本部门
+                    if current_user.dept_id != dataset.dept_id or current_user.current_role \
+                            not in (TenantAccountRole.ADMIN, TenantAccountRole.OWNER,TenantAccountRole.LEADER) \
+                            and current_user.id!=dataset.created_by:
+                        document.enable_applicant = current_user.id
+                        document.check_status = 1
+                        db.session.commit()
+                        return {"result": "该操作需要提交管理员审核后生效,请确认是否提交"}, 200
+
                 document.enabled = True
                 document.check_status = 3
                 document.disabled_at = None
@@ -888,11 +901,19 @@ class DocumentStatusApi(DocumentResource):
                     raise InvalidActionError(f"Document: {document.name} is not completed.")
                 if not document.enabled:
                     continue
-                #     下线判断,非管理员无法提交
-                if current_user.current_role not in (TenantAccountRole.ADMIN, TenantAccountRole.OWNER):
-                    document.enable_applicant = current_user.id
-                    db.session.commit()
-                    return {"result": "该操作需要提交管理员审核后生效,请确认是否提交"}, 200
+                if dataset.edit_auth == 1:
+                    if current_user != dataset.created_by:
+                        document.enable_applicant = current_user.id
+                        db.session.commit()
+                        return {"result": "该操作需要提交所有者审核后生效,请确认是否提交"}, 200
+                if dataset.edit_auth == 2:
+                    # 非本部门
+                    if current_user.dept_id != dataset.dept_id or current_user.current_role not in \
+                            (TenantAccountRole.ADMIN, TenantAccountRole.OWNER,TenantAccountRole.LEADER)\
+                            and current_user.id != dataset.created_by:
+                        document.enable_applicant = current_user.id
+                        db.session.commit()
+                        return {"result": "该操作需要提交管理员审核后生效,请确认是否提交"}, 200
 
                 document.enabled = False
                 document.disabled_at = datetime.now(UTC).replace(tzinfo=None)