-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: application model #3146
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
feat: application model #3146
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 |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| from django.utils.translation import gettext_lazy as _ | ||
| from rest_framework import serializers | ||
|
|
||
| from application.models.application import Application, ApplicationFolder | ||
| from common.constants.permission_constants import Group | ||
| from folders.api.folder import FolderCreateRequest | ||
| from knowledge.models import KnowledgeFolder, Knowledge | ||
|
|
@@ -18,8 +19,7 @@ def get_source_type(source): | |
| if source == Group.TOOL.name: | ||
| return Tool | ||
| elif source == Group.APPLICATION.name: | ||
| # todo app folder | ||
| return None | ||
| return Application | ||
| elif source == Group.KNOWLEDGE.name: | ||
| return Knowledge | ||
| else: | ||
|
|
@@ -30,8 +30,7 @@ def get_folder_type(source): | |
| if source == Group.TOOL.name: | ||
| return ToolFolder | ||
| elif source == Group.APPLICATION.name: | ||
| # todo app folder | ||
| return None | ||
| return ApplicationFolder | ||
| # return ApplicationFolder | ||
| elif source == Group.KNOWLEDGE.name: | ||
| return KnowledgeFolder | ||
|
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 provided code has a few minor issues that can be addressed:
Here's the revised code: from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from application.models.application import Application, ApplicationFolder
from common.constants.permission_constants import Group
from folders.api.folder import FolderCreateRequest
from knowledge.models import KnowledgeFolder, Knowledge
def get_source_type(source):
if source == Group.TOOL.name:
return Tool
elif source == Group.APPLICATION.name:
return Application
elif source == Group.KNOWLEDGE.name:
return Knowledge
else:
raise ValueError("Invalid group type")
def get_folder_type(source):
if source == Group.TOOL.name:
return ToolFolder
elif source == Group.APPLICATION.name:
return ApplicationFolder
elif source == Group.KNOWLEDGE.name:
return KnowledgeFolder
else:
raise ValueError("Invalid group type")Key Changes:
|
||
|
|
||
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.
The provided Django model code is mostly correct but has a few minor improvements and corrections I can suggest:
Improvements & Corrections
Import Statement: The import statement
import uuid_utils.compat as uuidsuggests that there might be an issue with the moduleuuid_utils.comp. Ensure that it exists and is correctly imported.File Upload Setting: In the
file_upload_settingfield in theApplicationmodel, consider adding more detail about what kind of settings could be stored here (e.g., supported formats, maximum file size).Documentation: There is no documentation (
@date, etc.) for most classes or methods. Adding comments would greatly help others understand their purpose and how to use them.Method Names: Ensure method names follow Django conventions and are descriptive. For example, use verbs where appropriate in method names like
get_model_setting_dict.Comments: Add comments explaining the logic behind each section, especially if they involve complex calculations or specific behaviors.
Default Values: For fields like
clean_time, you should add a comment indicating its unit (in seconds).Class Method: Consider whether all static methods within each class have clear and relevant purposes. Static methods without any dependency on instance attributes are better suited outside of classes.
Database Indexes: Review the database indexes to ensure they are not redundant or unnecessary, which can improve query performance.
Here's an enhanced version of your model with these suggestions incorporated: