Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions apps/common/constants/permission_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Group(Enum):
WORKSPACE = "WORKSPACE"
DISPLAY_SETTINGS = "DISPLAY_SETTINGS"
LOGIN_AUTH = "LOGIN_AUTH"
SYSTEM_API_KEY = "SYSTEM_API_KEY"
APPEARANCE_SETTINGS = "APPEARANCE_SETTINGS"


class SystemGroup(Enum):
Expand Down Expand Up @@ -213,6 +215,8 @@ def get_workspace_role(self):
Operate.RELATE.value: _("Relate"),
Group.LOGIN_AUTH.value: _("Login Auth"),
Group.DISPLAY_SETTINGS.value: _("Display Settings"),
Group.SYSTEM_API_KEY.value: _("System API Key"),
Group.APPEARANCE_SETTINGS.value:_("Appearance Settings")

}

Expand Down Expand Up @@ -520,6 +524,36 @@ class PermissionConstants(Enum):
parent_group=[SystemGroup.APPLICATION],
resource_permission_group_list=[ResourcePermissionGroup.VIEW],
)
SYSTEM_API_KEY_READ = Permission(group=Group.SYSTEM_API_KEY, operate=Operate.READ,
role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.SYSTEM_SETTING]
)
SYSTEM_API_KEY_EDIT = Permission(group=Group.SYSTEM_API_KEY, operate=Operate.EDIT,
role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.SYSTEM_SETTING]
)
SYSTEM_API_KEY_DELETE = Permission(group=Group.SYSTEM_API_KEY, operate=Operate.DELETE,
role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.SYSTEM_SETTING]
)
SYSTEM_API_KEY_CREATE = Permission(group=Group.SYSTEM_API_KEY, operate=Operate.CREATE,
role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.SYSTEM_SETTING]
)
APPEARANCE_SETTINGS_READ = Permission(group=Group.APPEARANCE_SETTINGS, operate=Operate.READ,
role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.SYSTEM_SETTING]
)
APPEARANCE_SETTINGS_EDIT = Permission(group=Group.APPEARANCE_SETTINGS, operate=Operate.EDIT,
role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.SYSTEM_SETTING]
)







def get_workspace_application_permission(self):
return lambda r, kwargs: Permission(group=self.value.group, operate=self.value.operate,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code appears to be well-formed and does not contain any immediate irregularities or obvious issues. However, here are a few general suggestions for improvement:

  1. Documentation Consistency: Ensure that all docstrings and comments follow consistent formatting guidelines. This can help make the code more readable and maintainable.

  2. Code Organization: The order of imports and class definitions looks appropriate, but consider organizing them further if needed. For example, placing common classes at the top and specific group-related constants near their use cases might improve readability.

  3. Variable Naming: While variable names like r and kwargs are short, they could be considered too generic unless there's a strong reason for their usage in that particular function. Using descriptive names would make the code easier to understand.

  4. Type Annotations: If applicable, adding type annotations (e.g., using mypy) can help ensure that variables and expected types are correctly defined, improving static typing checks.

  5. Permissions Management: The permission management part is organized well based on roles and groups. Consider whether each operation (read, edit, delete, create) should have a broader scope when considering system-wide capabilities rather than just individual resource operations.

Overall, your implementation has a solid structure and logical flow, making it ready for production use with minor adjustments for consistency and clarity.

Expand Down
66 changes: 66 additions & 0 deletions apps/locales/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -3672,3 +3672,69 @@ msgstr ""
#: workspace/views/workspace.py:180
msgid "Get workspace list by user"
msgstr ""

msgid "System API Key"
msgstr ""

msgid "msgid "Create SystemAPIKey"
msgstr ""

msgid "Get SystemAPIKey List"
msgstr ""

msgid "Update SystemAPIKey"
msgstr ""

msgid "Delete SystemAPIKey"
msgstr ""

msgid "Allow cross domain"
msgstr ""

msgid "Cross domain list"
msgstr ""

msgid "system API key id"
msgstr ""

msgid "View appearance settings"
msgstr ""

msgid "SystemParams"
msgstr ""

msgid "Update appearance settings"
msgstr ""

msgid "theme"
msgstr ""

msgid "login logo"
msgstr ""

msgid "login image"
msgstr ""

msgid "title"
msgstr ""

msgid "slogan"
msgstr ""

msgid "show user manual"
msgstr ""

msgid "user manual url"
msgstr ""

msgid "show forum"
msgstr ""

msgid "forum url"
msgstr ""

msgid "show project"
msgstr ""

msgid "project url"
msgstr ""
66 changes: 66 additions & 0 deletions apps/locales/zh_CN/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -3800,3 +3800,69 @@ msgstr "获取工作空间成员列表"
#: workspace/views/workspace.py:180
msgid "Get workspace list by user"
msgstr "根据用户获取工作空间列表"

msgid "System API Key"
msgstr "系统 API Key"

msgid "Create SystemAPIKey"
msgstr "创建系统 API 密钥"

msgid "Update SystemAPIKey"
msgstr "更新系统 API 密钥"

msgid "Get SystemAPIKey List"
msgstr "获取系统 API 密钥列表"

msgid "Delete SystemAPIKey"
msgstr "删除系统 API 密钥"

msgid "Allow cross domain"
msgstr "允许跨域"

msgid "Cross domain list"
msgstr "跨域列表"

msgid "system API key id"
msgstr "系统 API 密钥 ID"

msgid "View appearance settings"
msgstr "查看外观设置"

msgid "SystemParams"
msgstr "系统参数"

msgid "Update appearance settings"
msgstr "更新外观设置"

msgid "theme"
msgstr "主题"

msgid "login logo"
msgstr "登录 logo"

msgid "login image"
msgstr "登陆图片"

msgid "title"
msgstr "标题"

msgid "slogan"
msgstr "标语"

msgid "show user manual"
msgstr "显示用户手册"

msgid "user manual url"
msgstr "用户手册网址"

msgid "show forum"
msgstr "显示论坛"

msgid "forum url"
msgstr "论坛网址"

msgid "show project"
msgstr "显示项目"

msgid "project url"
msgstr "项目网址"
66 changes: 66 additions & 0 deletions apps/locales/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -3800,3 +3800,69 @@ msgstr "獲取工作空間成員列表"
#: workspace/views/workspace.py:180
msgid "Get workspace list by user"
msgstr "根據用戶獲取工作空間列表"

msgid "System API Key"
msgstr "系統 API Key"

msgid "Create SystemAPIKey"
msgstr "創建系統 API 密鑰"

msgid "Get SystemAPIKey List"
msgstr "獲取系統 API 密鑰清單"

msgid "Update SystemAPIKey"
msgstr "更新系統 API 密鑰"

msgid "Delete SystemAPIKey"
msgstr "刪除系統 API 密鑰"

msgid "Allow cross domain"
msgstr "允許跨域"

msgid "Cross domain list"
msgstr "跨域清單"

msgid "system API key id"
msgstr "系統 API 密鑰 ID"

msgid "View appearance settings"
msgstr "查看外觀設置"

msgid "SystemParams"
msgstr "系統參數"

msgid "Update appearance settings"
msgstr "更新外觀設置"

msgid "theme"
msgstr "主題"

msgid "login logo"
msgstr "登錄 logo"

msgid "login image"
msgstr "登錄圖片"

msgid "title"
msgstr "標題"

msgid "slogan"
msgstr "標語"

msgid "show user manual"
msgstr "顯示用戶手冊"

msgid "user manual url"
msgstr "用戶手冊網址"

msgid "show forum"
msgstr "顯示論壇"

msgid "forum url"
msgstr "論壇網址"

msgid "show project"
msgstr "顯示項目"

msgid "project url"
msgstr "項目網址"
Loading