Skip to content

Commit c4e392c

Browse files
committed
feat: add portal model, API, and configuration management
1 parent d5213d2 commit c4e392c

21 files changed

Lines changed: 487 additions & 10 deletions

File tree

‎apps/common/constants/permission_constants.py‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class Group(Enum):
104104
KNOWLEDGE_FOLDER = "KNOWLEDGE_FOLDER"
105105
TOOL_FOLDER = "TOOL_FOLDER"
106106
CHAT_USER_GROUP = "CHAT_USER_GROUP"
107+
PORTAL = "PORTAL"
107108

108109

109110
class SystemGroup(Enum):
@@ -127,6 +128,7 @@ class SystemGroup(Enum):
127128
CHAT_USER = "CHAT_USER"
128129
CHAT_USER_GROUP = "CHAT_USER_GROUP"
129130
CHAT_USER_AUTH = "CHAT_USER_AUTH"
131+
PORTAL = "PORTAL"
130132
OPERATION_LOG = "OPERATION_LOG"
131133
APPEARANCE_SETTINGS = "APPEARANCE_SETTINGS"
132134
LOGIN_AUTH = "LOGIN_AUTH"
@@ -181,7 +183,6 @@ class TopLevelGroup(Enum):
181183
OTHER = "OTHER"
182184

183185

184-
185186
class Operate(Enum):
186187
"""
187188
一个权限组的操作权限
@@ -487,6 +488,7 @@ def get_workspace_role(self):
487488
TopLevelGroup.CHAT_CLIENT.value: _("Chat Client"),
488489
SystemGroup.CHAT_USER_GROUP.value: _("Chat User Group"),
489490
SystemGroup.CHAT_USER_AUTH.value: _("Chat User Auth"),
491+
SystemGroup.PORTAL.value: _("Portal"),
490492
}
491493
GROUPS = {
492494
TopLevelGroup.IAM: (
@@ -515,6 +517,7 @@ def get_workspace_role(self):
515517
SystemGroup.CHAT_USER,
516518
SystemGroup.CHAT_USER_GROUP,
517519
SystemGroup.CHAT_USER_AUTH,
520+
SystemGroup.PORTAL,
518521
WorkspaceGroup.CHAT_USER,
519522
WorkspaceGroup.CHAT_USER_GROUP,
520523
),
@@ -589,11 +592,11 @@ def __str__(self):
589592
def __eq__(self, other):
590593
if isinstance(other, Permission):
591594
return (
592-
self.group == other.group
593-
and self.operate == other.operate
594-
and self.resource_path == other.resource_path
595-
and self.parent_group == other.parent_group
596-
and self.is_ee == other.is_ee
595+
self.group == other.group
596+
and self.operate == other.operate
597+
and self.resource_path == other.resource_path
598+
and self.parent_group == other.parent_group
599+
and self.is_ee == other.is_ee
597600
)
598601
return str(self) == str(other)
599602

@@ -1533,6 +1536,15 @@ class PermissionConstants(Enum):
15331536
role_list=[RoleConstants.ADMIN],
15341537
parent_group=[SystemGroup.CHAT_USER_AUTH]
15351538
)
1539+
PORTAL_READ = Permission(group=Group.PORTAL, operate=Operate.READ,
1540+
role_list=[RoleConstants.ADMIN],
1541+
parent_group=[SystemGroup.PORTAL]
1542+
)
1543+
PORTAL_EDIT = Permission(group=Group.PORTAL, operate=Operate.EDIT,
1544+
role_list=[RoleConstants.ADMIN],
1545+
parent_group=[SystemGroup.PORTAL]
1546+
)
1547+
15361548
WORKSPACE_CHAT_USER_READ = Permission(group=Group.WORKSPACE_CHAT_USER, operate=Operate.READ,
15371549
role_list=[RoleConstants.ADMIN],
15381550
parent_group=[WorkspaceGroup.CHAT_USER]

‎apps/locales/en_US/LC_MESSAGES/django.po‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9450,4 +9450,46 @@ msgid "Edit user group authorization status of resource"
94509450
msgstr ""
94519451

94529452
msgid "Get user group authorization status of resource by page"
9453+
msgstr ""
9454+
9455+
msgid "Get portal configuration"
9456+
msgstr ""
9457+
9458+
msgid "Save portal configuration"
9459+
msgstr ""
9460+
9461+
msgid "Portal"
9462+
msgstr ""
9463+
9464+
msgid "Portal configuration does not exist"
9465+
msgstr ""
9466+
9467+
msgid "portal name"
9468+
msgstr ""
9469+
9470+
msgid "portal description"
9471+
msgstr ""
9472+
9473+
msgid "portal logo"
9474+
msgstr ""
9475+
9476+
msgid "tab logo"
9477+
msgstr ""
9478+
9479+
msgid "enable public access"
9480+
msgstr ""
9481+
9482+
msgid "enable api"
9483+
msgstr ""
9484+
9485+
msgid "enable auth"
9486+
msgstr ""
9487+
9488+
msgid "auth config"
9489+
msgstr ""
9490+
9491+
msgid "enable cors"
9492+
msgstr ""
9493+
9494+
msgid "cors config"
94539495
msgstr ""

‎apps/locales/zh_CN/LC_MESSAGES/django.po‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9574,4 +9574,46 @@ msgid "Edit user group authorization status of resource"
95749574
msgstr "编辑用户组对资源的授权状态"
95759575

95769576
msgid "Get user group authorization status of resource by page"
9577-
msgstr "分页获取用户组对资源的授权状态"
9577+
msgstr "分页获取用户组对资源的授权状态"
9578+
9579+
msgid "Get portal configuration"
9580+
msgstr "获取门户配置"
9581+
9582+
msgid "Save portal configuration"
9583+
msgstr "保存门户配置"
9584+
9585+
msgid "Portal"
9586+
msgstr "门户"
9587+
9588+
msgid "Portal configuration does not exist"
9589+
msgstr "门户配置不存在"
9590+
9591+
msgid "portal name"
9592+
msgstr "门户名称"
9593+
9594+
msgid "portal description"
9595+
msgstr "门户描述"
9596+
9597+
msgid "portal logo"
9598+
msgstr "门户Logo"
9599+
9600+
msgid "tab logo"
9601+
msgstr "浏览器Tab Logo"
9602+
9603+
msgid "enable public access"
9604+
msgstr "是否开启公开访问"
9605+
9606+
msgid "enable api"
9607+
msgstr "是否开启API服务"
9608+
9609+
msgid "enable auth"
9610+
msgstr "是否开启身份认证"
9611+
9612+
msgid "auth config"
9613+
msgstr "身份认证配置"
9614+
9615+
msgid "enable cors"
9616+
msgstr "是否开启跨域设置"
9617+
9618+
msgid "cors config"
9619+
msgstr "跨域配置"

‎apps/locales/zh_Hant/LC_MESSAGES/django.po‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9573,4 +9573,46 @@ msgid "Edit user group authorization status of resource"
95739573
msgstr "編輯用戶組對資源的授權狀態"
95749574

95759575
msgid "Get user group authorization status of resource by page"
9576-
msgstr "分頁獲取用戶組對資源的授權狀態"
9576+
msgstr "分頁獲取用戶組對資源的授權狀態"
9577+
9578+
msgid "Get portal configuration"
9579+
msgstr "獲取門戶配置"
9580+
9581+
msgid "Save portal configuration"
9582+
msgstr "儲存門戶配置"
9583+
9584+
msgid "Portal"
9585+
msgstr "門戶"
9586+
9587+
msgid "Portal configuration does not exist"
9588+
msgstr "門戶配置不存在"
9589+
9590+
msgid "portal name"
9591+
msgstr "門戶名稱"
9592+
9593+
msgid "portal description"
9594+
msgstr "門戶描述"
9595+
9596+
msgid "portal logo"
9597+
msgstr "門戶Logo"
9598+
9599+
msgid "tab logo"
9600+
msgstr "瀏覽器Tab Logo"
9601+
9602+
msgid "enable public access"
9603+
msgstr "是否開啟公開訪問"
9604+
9605+
msgid "enable api"
9606+
msgstr "是否開啟API服務"
9607+
9608+
msgid "enable auth"
9609+
msgstr "是否開啟身份認證"
9610+
9611+
msgid "auth config"
9612+
msgstr "身份認證配置"
9613+
9614+
msgid "enable cors"
9615+
msgstr "是否開啟跨域設置"
9616+
9617+
msgid "cors config"
9618+
msgstr "跨域配置"

‎apps/maxkb/settings/base/web.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
@date:2025/11/5 14:53
77
@desc:
88
"""
9-
from pathlib import Path
10-
from ...const import CONFIG, PROJECT_DIR
119
import os
10+
from pathlib import Path
11+
1212
from django.utils.translation import gettext_lazy as _
1313

14+
from ...const import CONFIG, PROJECT_DIR
15+
1416
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1517
BASE_DIR = Path(__file__).resolve().parent.parent.parent
1618

@@ -46,6 +48,7 @@
4648
'oss',
4749
'trigger',
4850
'django_apscheduler',
51+
"portal"
4952
]
5053

5154
MIDDLEWARE = [

‎apps/maxkb/urls/web.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
path(admin_api_prefix, include("trigger.urls")),
4545
path(admin_api_prefix, include("oss.urls")),
4646
path(admin_api_prefix, include("homepage.urls")),
47+
path(admin_api_prefix, include("portal.urls")),
4748
path(chat_api_prefix, include("oss.urls")),
4849
path(chat_api_prefix, include("chat.urls")),
4950
path(f'{admin_ui_prefix[1:]}/', include('oss.retrieval_urls')),

‎apps/portal/__init__.py‎

Whitespace-only changes.

‎apps/portal/admin.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

‎apps/portal/api/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# coding=utf-8
2+
from .portal import *

‎apps/portal/api/portal.py‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# coding=utf-8
2+
"""
3+
@project: MaxKB
4+
@Author:MaxKB
5+
@file: portal.py
6+
@date:2026/8/3
7+
@desc: 门户API文档
8+
"""
9+
from common.mixins.api_mixin import APIMixin
10+
from common.result import DefaultResultSerializer
11+
12+
13+
class PortalAPI(APIMixin):
14+
15+
class Get(APIMixin):
16+
@staticmethod
17+
def get_response():
18+
return DefaultResultSerializer
19+
20+
class Save(APIMixin):
21+
@staticmethod
22+
def get_request():
23+
return {
24+
'multipart/form-data': {
25+
'type': 'object',
26+
'properties': {
27+
'name': {'type': 'string', 'description': '门户名称'},
28+
'description': {'type': 'string', 'description': '门户描述'},
29+
'logo': {'type': 'string', 'format': 'binary', 'description': '门户Logo'},
30+
'tab_logo': {'type': 'string', 'format': 'binary', 'description': '浏览器Tab Logo'},
31+
'enable_public_access': {'type': 'boolean', 'description': '是否开启公开访问'},
32+
'enable_api': {'type': 'boolean', 'description': '是否开启API服务'},
33+
'enable_auth': {'type': 'boolean', 'description': '是否开启身份认证'},
34+
'auth_config': {'type': 'object', 'description': '身份认证配置'},
35+
'enable_cors': {'type': 'boolean', 'description': '是否开启跨域设置'},
36+
'cors_config': {'type': 'object', 'description': '跨域配置'},
37+
}
38+
}
39+
}
40+
41+
@staticmethod
42+
def get_response():
43+
return DefaultResultSerializer

0 commit comments

Comments
 (0)