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
24 changes: 18 additions & 6 deletions apps/common/constants/permission_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class Group(Enum):
KNOWLEDGE_FOLDER = "KNOWLEDGE_FOLDER"
TOOL_FOLDER = "TOOL_FOLDER"
CHAT_USER_GROUP = "CHAT_USER_GROUP"
PORTAL = "PORTAL"


class SystemGroup(Enum):
Expand All @@ -127,6 +128,7 @@ class SystemGroup(Enum):
CHAT_USER = "CHAT_USER"
CHAT_USER_GROUP = "CHAT_USER_GROUP"
CHAT_USER_AUTH = "CHAT_USER_AUTH"
PORTAL = "PORTAL"
OPERATION_LOG = "OPERATION_LOG"
APPEARANCE_SETTINGS = "APPEARANCE_SETTINGS"
LOGIN_AUTH = "LOGIN_AUTH"
Expand Down Expand Up @@ -181,7 +183,6 @@ class TopLevelGroup(Enum):
OTHER = "OTHER"



class Operate(Enum):
"""
一个权限组的操作权限
Expand Down Expand Up @@ -487,6 +488,7 @@ def get_workspace_role(self):
TopLevelGroup.CHAT_CLIENT.value: _("Chat Client"),
SystemGroup.CHAT_USER_GROUP.value: _("Chat User Group"),
SystemGroup.CHAT_USER_AUTH.value: _("Chat User Auth"),
SystemGroup.PORTAL.value: _("Portal"),
}
GROUPS = {
TopLevelGroup.IAM: (
Expand Down Expand Up @@ -515,6 +517,7 @@ def get_workspace_role(self):
SystemGroup.CHAT_USER,
SystemGroup.CHAT_USER_GROUP,
SystemGroup.CHAT_USER_AUTH,
SystemGroup.PORTAL,
WorkspaceGroup.CHAT_USER,
WorkspaceGroup.CHAT_USER_GROUP,
),
Expand Down Expand Up @@ -589,11 +592,11 @@ def __str__(self):
def __eq__(self, other):
if isinstance(other, Permission):
return (
self.group == other.group
and self.operate == other.operate
and self.resource_path == other.resource_path
and self.parent_group == other.parent_group
and self.is_ee == other.is_ee
self.group == other.group
and self.operate == other.operate
and self.resource_path == other.resource_path
and self.parent_group == other.parent_group
and self.is_ee == other.is_ee
)
return str(self) == str(other)

Expand Down Expand Up @@ -1533,6 +1536,15 @@ class PermissionConstants(Enum):
role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.CHAT_USER_AUTH]
)
PORTAL_READ = Permission(group=Group.PORTAL, operate=Operate.READ,
role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.PORTAL]
)
PORTAL_EDIT = Permission(group=Group.PORTAL, operate=Operate.EDIT,
role_list=[RoleConstants.ADMIN],
parent_group=[SystemGroup.PORTAL]
)

WORKSPACE_CHAT_USER_READ = Permission(group=Group.WORKSPACE_CHAT_USER, operate=Operate.READ,
role_list=[RoleConstants.ADMIN],
parent_group=[WorkspaceGroup.CHAT_USER]
Expand Down
42 changes: 42 additions & 0 deletions apps/locales/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9450,4 +9450,46 @@ msgid "Edit user group authorization status of resource"
msgstr ""

msgid "Get user group authorization status of resource by page"
msgstr ""

msgid "Get portal configuration"
msgstr ""

msgid "Save portal configuration"
msgstr ""

msgid "Portal"
msgstr ""

msgid "Portal configuration does not exist"
msgstr ""

msgid "portal name"
msgstr ""

msgid "portal description"
msgstr ""

msgid "portal logo"
msgstr ""

msgid "tab logo"
msgstr ""

msgid "enable public access"
msgstr ""

msgid "enable api"
msgstr ""

msgid "enable auth"
msgstr ""

msgid "auth config"
msgstr ""

msgid "enable cors"
msgstr ""

msgid "cors config"
msgstr ""
44 changes: 43 additions & 1 deletion apps/locales/zh_CN/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9574,4 +9574,46 @@ msgid "Edit user group authorization status of resource"
msgstr "编辑用户组对资源的授权状态"

msgid "Get user group authorization status of resource by page"
msgstr "分页获取用户组对资源的授权状态"
msgstr "分页获取用户组对资源的授权状态"

msgid "Get portal configuration"
msgstr "获取门户配置"

msgid "Save portal configuration"
msgstr "保存门户配置"

msgid "Portal"
msgstr "门户"

msgid "Portal configuration does not exist"
msgstr "门户配置不存在"

msgid "portal name"
msgstr "门户名称"

msgid "portal description"
msgstr "门户描述"

msgid "portal logo"
msgstr "门户Logo"

msgid "tab logo"
msgstr "浏览器Tab Logo"

msgid "enable public access"
msgstr "是否开启公开访问"

msgid "enable api"
msgstr "是否开启API服务"

msgid "enable auth"
msgstr "是否开启身份认证"

msgid "auth config"
msgstr "身份认证配置"

msgid "enable cors"
msgstr "是否开启跨域设置"

msgid "cors config"
msgstr "跨域配置"
44 changes: 43 additions & 1 deletion apps/locales/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9573,4 +9573,46 @@ msgid "Edit user group authorization status of resource"
msgstr "編輯用戶組對資源的授權狀態"

msgid "Get user group authorization status of resource by page"
msgstr "分頁獲取用戶組對資源的授權狀態"
msgstr "分頁獲取用戶組對資源的授權狀態"

msgid "Get portal configuration"
msgstr "獲取門戶配置"

msgid "Save portal configuration"
msgstr "儲存門戶配置"

msgid "Portal"
msgstr "門戶"

msgid "Portal configuration does not exist"
msgstr "門戶配置不存在"

msgid "portal name"
msgstr "門戶名稱"

msgid "portal description"
msgstr "門戶描述"

msgid "portal logo"
msgstr "門戶Logo"

msgid "tab logo"
msgstr "瀏覽器Tab Logo"

msgid "enable public access"
msgstr "是否開啟公開訪問"

msgid "enable api"
msgstr "是否開啟API服務"

msgid "enable auth"
msgstr "是否開啟身份認證"

msgid "auth config"
msgstr "身份認證配置"

msgid "enable cors"
msgstr "是否開啟跨域設置"

msgid "cors config"
msgstr "跨域配置"
7 changes: 5 additions & 2 deletions apps/maxkb/settings/base/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
@date:2025/11/5 14:53
@desc:
"""
from pathlib import Path
from ...const import CONFIG, PROJECT_DIR
import os
from pathlib import Path

from django.utils.translation import gettext_lazy as _

from ...const import CONFIG, PROJECT_DIR

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent

Expand Down Expand Up @@ -46,6 +48,7 @@
'oss',
'trigger',
'django_apscheduler',
"portal"
]

MIDDLEWARE = [
Expand Down
1 change: 1 addition & 0 deletions apps/maxkb/urls/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
path(admin_api_prefix, include("trigger.urls")),
path(admin_api_prefix, include("oss.urls")),
path(admin_api_prefix, include("homepage.urls")),
path(admin_api_prefix, include("portal.urls")),
path(chat_api_prefix, include("oss.urls")),
path(chat_api_prefix, include("chat.urls")),
path(f'{admin_ui_prefix[1:]}/', include('oss.retrieval_urls')),
Expand Down
Empty file added apps/portal/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions apps/portal/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
2 changes: 2 additions & 0 deletions apps/portal/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# coding=utf-8
from .portal import *
43 changes: 43 additions & 0 deletions apps/portal/api/portal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding=utf-8
"""
@project: MaxKB
@Author:MaxKB
@file: portal.py
@date:2026/8/3
@desc: 门户API文档
"""
from common.mixins.api_mixin import APIMixin
from common.result import DefaultResultSerializer


class PortalAPI(APIMixin):

class Get(APIMixin):
@staticmethod
def get_response():
return DefaultResultSerializer

class Save(APIMixin):
@staticmethod
def get_request():
return {
'multipart/form-data': {
'type': 'object',
'properties': {
'name': {'type': 'string', 'description': '门户名称'},
'description': {'type': 'string', 'description': '门户描述'},
'logo': {'type': 'string', 'format': 'binary', 'description': '门户Logo'},
'tab_logo': {'type': 'string', 'format': 'binary', 'description': '浏览器Tab Logo'},
'enable_public_access': {'type': 'boolean', 'description': '是否开启公开访问'},
'enable_api': {'type': 'boolean', 'description': '是否开启API服务'},
'enable_auth': {'type': 'boolean', 'description': '是否开启身份认证'},
'auth_config': {'type': 'object', 'description': '身份认证配置'},
'enable_cors': {'type': 'boolean', 'description': '是否开启跨域设置'},
'cors_config': {'type': 'object', 'description': '跨域配置'},
}
}
}

@staticmethod
def get_response():
return DefaultResultSerializer
5 changes: 5 additions & 0 deletions apps/portal/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class PortalConfig(AppConfig):
name = 'portal'
52 changes: 52 additions & 0 deletions apps/portal/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Generated by Django 6.0.7 on 2026-08-03 06:20

import uuid_utils.compat
from django.db import migrations, models

def create_default_portal(apps, schema_editor):
Portal = apps.get_model("portal", "Portal")

Portal.objects.create(
name="智能体门户",
description="默认门户",
enable_public_access=True,
enable_api=True,
enable_auth=False,
auth_config={},
enable_cors=False,
cors_config={},
)

class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Portal',
fields=[
('create_time', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, db_index=True, verbose_name='修改时间')),
('name', models.CharField(default='智能体门户', max_length=64, verbose_name='门户名称')),
('description', models.TextField(blank=True, max_length=256, null=True, verbose_name='门户描述')),
('logo', models.CharField(blank=True, max_length=512, null=True, verbose_name='门户Logo地址')),
('tab_logo', models.CharField(blank=True, max_length=512, null=True, verbose_name='浏览器Tab Logo地址')),
('enable_public_access', models.BooleanField(default=True, verbose_name='是否开启公开访问')),
('enable_api', models.BooleanField(default=True, verbose_name='是否开启API服务')),
('enable_auth', models.BooleanField(default=False, verbose_name='是否开启身份认证')),
('auth_config', models.JSONField(blank=True, default=dict, verbose_name='身份认证配置')),
('enable_cors', models.BooleanField(default=False, verbose_name='是否开启跨域设置')),
('cors_config', models.JSONField(blank=True, default=dict, verbose_name='跨域配置')),
],
options={
'db_table': 'portal',
},
),
migrations.RunPython(
create_default_portal,
migrations.RunPython.noop,
),
]
Empty file.
1 change: 1 addition & 0 deletions apps/portal/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .portal import *
Loading
Loading