-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Upload documents from the workflow knowledge base #4414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,7 +39,7 @@ | |
| >{{ $t('views.document.importDocument') }} | ||
| </el-button> | ||
| <el-button | ||
| v-if="knowledgeDetail?.type === 4 && permissionPrecise.doc_create(id)" | ||
| v-if="knowledgeDetail?.type === 4 && permissionPrecise.doc_create(id)&&knowledgeDetail.is_publish" | ||
| type="primary" | ||
| @click=" | ||
| router.push({ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code snippet has a couple of minor issues:
To address these points, I've made the necessary changes below: @@ -39,8 +39,8 @@
>{{ $t('views.document.importDocument') }}
</el-button>
<el-button
- v-if="knowledgeDetail?.type === 4 && permissionPrecise.doc_create(id)"
+ v-if="knowledgeDetail?.type === 4 && permissionPrecise.doc_create(knowledgeDetail.id) && knowledgeDetail.is_publish"
type="primary"
@click="
router.push({I've also added comments explaining each modification to improve readability and maintainability. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no critical issue in this code snippet. However, here are some general points to consider:
Code Duplication: The line
QuerySet(KnowledgeWorkflow).update_or_create(...)appears twice in the same function body. This could be optimized into a single call.Default Values: It's generally good practice to ensure that default values are not set explicitly within Django queries unless necessary. In this case, setting default values like UUIDs can lead to unnecessary database writes.
Data Validation: Ensure that all data received as input follows expected formats and types, especially before processing it with database operations.
Comments: While there are comments, they might need more clarity or explanation.
Here’s an improved version of the code based on these considerations:
Key Changes:
queryset.update_or_createcalls..one()instead of filtering directly.KnowledgeWorkflowrecord is found.