|
@@ -53,6 +53,7 @@ from fields.document_fields import (
|
|
from libs.login import login_required
|
|
from libs.login import login_required
|
|
from models import Dataset, DatasetProcessRule, Document, DocumentSegment, UploadFile
|
|
from models import Dataset, DatasetProcessRule, Document, DocumentSegment, UploadFile
|
|
from models.account import TenantAccountRole
|
|
from models.account import TenantAccountRole
|
|
|
|
+from services.account_service import AccountService
|
|
from services.dataset_service import DatasetService, DocumentService
|
|
from services.dataset_service import DatasetService, DocumentService
|
|
from services.entities.knowledge_entities.knowledge_entities import KnowledgeConfig
|
|
from services.entities.knowledge_entities.knowledge_entities import KnowledgeConfig
|
|
from tasks.add_document_to_index_task import add_document_to_index_task
|
|
from tasks.add_document_to_index_task import add_document_to_index_task
|
|
@@ -224,8 +225,22 @@ class DatasetDocumentListApi(Resource):
|
|
).count()
|
|
).count()
|
|
document.completed_segments = completed_segments
|
|
document.completed_segments = completed_segments
|
|
document.total_segments = total_segments
|
|
document.total_segments = total_segments
|
|
|
|
+ if document.check_by is not None:
|
|
|
|
+ check_account = AccountService.get_user_through_id(document.check_by)
|
|
|
|
+ document.check_by = check_account.name
|
|
|
|
+ if document.enable_applicant is not None:
|
|
|
|
+ applicant_account = (AccountService.get_user_through_id(document.enable_applicant),)
|
|
|
|
+ document.enable_applicant = applicant_account.name
|
|
data = marshal(documents, document_with_segments_fields)
|
|
data = marshal(documents, document_with_segments_fields)
|
|
else:
|
|
else:
|
|
|
|
+ for document in documents:
|
|
|
|
+ if document.check_by is not None:
|
|
|
|
+ check_account = AccountService.get_user_through_id(document.check_by)
|
|
|
|
+ document.check_by = check_account.name
|
|
|
|
+ if document.enable_applicant is not None:
|
|
|
|
+ applicant_account = AccountService.get_user_through_id(document.enable_applicant)
|
|
|
|
+ document.enable_applicant = applicant_account.name
|
|
|
|
+
|
|
data = marshal(documents, document_fields)
|
|
data = marshal(documents, document_fields)
|
|
response = {
|
|
response = {
|
|
"data": data,
|
|
"data": data,
|
|
@@ -655,6 +670,10 @@ class DocumentDetailApi(DocumentResource):
|
|
"display_status": document.display_status,
|
|
"display_status": document.display_status,
|
|
"doc_form": document.doc_form,
|
|
"doc_form": document.doc_form,
|
|
"doc_language": document.doc_language,
|
|
"doc_language": document.doc_language,
|
|
|
|
+ "check_status": document.check_status,
|
|
|
|
+ "check_at": document.check_at,
|
|
|
|
+ "disable_application": document.disable_applicant,
|
|
|
|
+ "enable_application": document.enable_applicant,
|
|
}
|
|
}
|
|
else:
|
|
else:
|
|
dataset_process_rules = DatasetService.get_process_rules(dataset_id)
|
|
dataset_process_rules = DatasetService.get_process_rules(dataset_id)
|
|
@@ -690,6 +709,10 @@ class DocumentDetailApi(DocumentResource):
|
|
"display_status": document.display_status,
|
|
"display_status": document.display_status,
|
|
"doc_form": document.doc_form,
|
|
"doc_form": document.doc_form,
|
|
"doc_language": document.doc_language,
|
|
"doc_language": document.doc_language,
|
|
|
|
+ "check_status": document.check_status,
|
|
|
|
+ "check_at": document.check_at,
|
|
|
|
+ "disable_application": document.disable_applicant,
|
|
|
|
+ "enable_application": document.enable_applicant,
|
|
}
|
|
}
|
|
|
|
|
|
return response, 200
|
|
return response, 200
|
|
@@ -834,9 +857,9 @@ class DocumentStatusApi(DocumentResource):
|
|
if action == "enable":
|
|
if action == "enable":
|
|
if document.enabled:
|
|
if document.enabled:
|
|
continue
|
|
continue
|
|
- if current_user.current_role != TenantAccountRole.ADMIN:
|
|
|
|
|
|
+ if current_user not in (TenantAccountRole.ADMIN, TenantAccountRole.OWNER):
|
|
document.enable_applicant = current_user.id
|
|
document.enable_applicant = current_user.id
|
|
- document.check_status=1
|
|
|
|
|
|
+ document.check_status = 1
|
|
db.session.commit()
|
|
db.session.commit()
|
|
return {"result": "该操作需要提交管理员审核后生效,请确认是否提交"}, 200
|
|
return {"result": "该操作需要提交管理员审核后生效,请确认是否提交"}, 200
|
|
document.enabled = True
|
|
document.enabled = True
|
|
@@ -857,7 +880,7 @@ class DocumentStatusApi(DocumentResource):
|
|
document.enabled = False
|
|
document.enabled = False
|
|
document.check_by = current_user.id
|
|
document.check_by = current_user.id
|
|
document.updated_at = datetime.now(UTC).replace(tzinfo=None)
|
|
document.updated_at = datetime.now(UTC).replace(tzinfo=None)
|
|
- document.check_status = 4
|
|
|
|
|
|
+ document.check_status = 2
|
|
db.session.commit()
|
|
db.session.commit()
|
|
|
|
|
|
elif action == "disable":
|
|
elif action == "disable":
|
|
@@ -866,12 +889,10 @@ class DocumentStatusApi(DocumentResource):
|
|
if not document.enabled:
|
|
if not document.enabled:
|
|
continue
|
|
continue
|
|
# 下线判断,非管理员无法提交
|
|
# 下线判断,非管理员无法提交
|
|
- if current_user.current_role != TenantAccountRole.ADMIN:
|
|
|
|
- document.disable_applicant = current_user.id
|
|
|
|
|
|
+ if current_user.current_role not in (TenantAccountRole.ADMIN, TenantAccountRole.OWNER):
|
|
|
|
+ document.enable_applicant = current_user.id
|
|
db.session.commit()
|
|
db.session.commit()
|
|
- # data = {"result": "该操作需要提交管理员审核后生效,请确认是否提交"}
|
|
|
|
return {"result": "该操作需要提交管理员审核后生效,请确认是否提交"}, 200
|
|
return {"result": "该操作需要提交管理员审核后生效,请确认是否提交"}, 200
|
|
- # return json.dumps(data, ensure_ascii=False), 200
|
|
|
|
|
|
|
|
document.enabled = False
|
|
document.enabled = False
|
|
document.disabled_at = datetime.now(UTC).replace(tzinfo=None)
|
|
document.disabled_at = datetime.now(UTC).replace(tzinfo=None)
|