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
14 changes: 9 additions & 5 deletions apps/common/auth/constants/category_constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# coding=utf-8
"""
@project: MaxKB
@Author:虎虎虎
@file: category_constants.py
@date:2026/8/3 17:31
@desc: 一级目录分类常量(最顶层分类)
@project: MaxKB
@Author:虎虎虎
@file: category_constants.py
@date:2026/8/3 17:31
@desc: 一级目录分类常量(最顶层分类)
"""

from enum import Enum
from django.utils.translation import gettext_lazy as _

Expand All @@ -14,6 +15,9 @@ class Category(Enum):
"""
一级目录(最顶层分类),用于在 parent_group 之上再加一层分类
"""

# 概览
HOME = ("HOME", _("Home page"))
# 身份与权限
IAM = ("IAM", _("IAM"))
# 资源管理
Expand Down
8 changes: 6 additions & 2 deletions apps/common/auth/constants/permission_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ class PermissionConstants(Enum):

SYSTEM_HOMEPAGE_READ = (
Permission(group=Group.SYSTEM_HOMEPAGE, sub_group=Group.SYSTEM_HOMEPAGE, operate=Operate.READ, bit_index=0),
PermissionMeta(role_list=[RoleConstants.ADMIN], category=Category.IAM, scope=[PermissionScopeConstants.SYSTEM]),
PermissionMeta(
role_list=[RoleConstants.ADMIN], category=Category.HOME, scope=[PermissionScopeConstants.SYSTEM]
),
)

SYSTEM_HOMEPAGE_EXPORT = (
Permission(group=Group.SYSTEM_HOMEPAGE, sub_group=Group.SYSTEM_HOMEPAGE, operate=Operate.EXPORT, bit_index=1),
PermissionMeta(role_list=[RoleConstants.ADMIN], category=Category.IAM, scope=[PermissionScopeConstants.SYSTEM]),
PermissionMeta(
role_list=[RoleConstants.ADMIN], category=Category.HOME, scope=[PermissionScopeConstants.SYSTEM]
),
)

# ==================== 资源主分组(无子分组) ====================
Expand Down
12 changes: 8 additions & 4 deletions apps/common/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import secrets
import shutil
import uuid
from functools import reduce
from functools import lru_cache, reduce
from typing import Dict, List

import pytz
Expand Down Expand Up @@ -197,10 +197,14 @@ def markdown_to_plain_text(md: str) -> str:
return text


def get_file_content(path):
@lru_cache(maxsize=None)
def get_file_content(path: str) -> str:
"""
Read static resource files (SQL templates, prompts, forms).
Results are cached because these files do not change at runtime.
"""
with open(path, "r", encoding="utf-8") as file:
content = file.read()
return content
return file.read()


def sub_array(array: List, item_num=10):
Expand Down
Loading
Loading