Merge remote-tracking branch 'origin/dvadmin-dev' into dvadmin-dev
# Conflicts: # dvadmin-ui/src/components/DeptTree/index.vue # dvadmin-ui/src/components/UsersTree/index.vue # dvadmin-ui/src/main.jspull/31/head
commit
8ab85d24bf
|
@ -285,7 +285,7 @@ REST_FRAMEWORK = {
|
||||||
),
|
),
|
||||||
|
|
||||||
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema',
|
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema',
|
||||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
'DEFAULT_PAGINATION_CLASS': 'vadmin.op_drf.pagination.Pagination',
|
||||||
'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
|
'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
|
||||||
'EXCEPTION_HANDLER': 'apps.vadmin.utils.exceptions.op_exception_handler',
|
'EXCEPTION_HANDLER': 'apps.vadmin.utils.exceptions.op_exception_handler',
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
from logging import StreamHandler, getLevelName
|
|
||||||
from logging.handlers import RotatingFileHandler
|
|
||||||
from typing import Optional, IO
|
|
||||||
|
|
||||||
|
|
||||||
class MyStreamHandler(StreamHandler):
|
|
||||||
|
|
||||||
def __init__(self, stream: Optional[IO[str]] = ...) -> None:
|
|
||||||
print(222)
|
|
||||||
super().__init__(stream)
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
level = getLevelName(self.level)
|
|
||||||
name = getattr(self.stream, 'name', '')
|
|
||||||
# bpo-36015: name can be an int
|
|
||||||
name = str(name)
|
|
||||||
if name:
|
|
||||||
name += ' '
|
|
||||||
print(111)
|
|
||||||
return '<%s %s(%s)>' % (self.__class__.__name__, name, level)
|
|
||||||
class MyRotatingFileHandler(RotatingFileHandler):
|
|
||||||
|
|
||||||
def __init__(self, filename: str, mode: str = ..., maxBytes: int = ..., backupCount: int = ...,
|
|
||||||
encoding: Optional[str] = ..., delay: bool = ...) -> None:
|
|
||||||
print(4444)
|
|
||||||
super().__init__(filename, mode, maxBytes, backupCount, encoding, delay)
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
level = getLevelName(self.level)
|
|
||||||
print(22)
|
|
||||||
return '<%s %s (%s)>' % (self.__class__.__name__, self.baseFilename, level)
|
|
|
@ -45,7 +45,7 @@ class GenericAPIView(CustomAPIView):
|
||||||
filter_backends = api_settings.DEFAULT_FILTER_BACKENDS
|
filter_backends = api_settings.DEFAULT_FILTER_BACKENDS
|
||||||
|
|
||||||
# The style to use for queryset pagination.
|
# The style to use for queryset pagination.
|
||||||
pagination_class = Pagination
|
pagination_class = api_settings.DEFAULT_PAGINATION_CLASS
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
from application.settings import BASE_DIR
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
"""
|
||||||
|
创建App命令:
|
||||||
|
python manage.py createapp app名
|
||||||
|
python manage.py createapp app01 app02 ...
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument('app_name', nargs='*', type=str, )
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
app_name = options.get('app_name')
|
||||||
|
for name in app_name:
|
||||||
|
app_path = os.path.join(BASE_DIR, "apps", name)
|
||||||
|
# 判断app是否存在
|
||||||
|
if os.path.exists(app_path):
|
||||||
|
print(f"创建失败,App {name} 已存在!")
|
||||||
|
break
|
||||||
|
source_path = os.path.join(BASE_DIR, "apps", "vadmin", "template")
|
||||||
|
target_path = app_path
|
||||||
|
if not os.path.exists(target_path):
|
||||||
|
# 如果目标路径不存在原文件夹的话就创建
|
||||||
|
os.makedirs(target_path)
|
||||||
|
if os.path.exists(source_path):
|
||||||
|
# 如果目标路径存在原文件夹的话就先删除
|
||||||
|
shutil.rmtree(target_path)
|
||||||
|
shutil.copytree(source_path, target_path)
|
||||||
|
# 修改app中的apps 内容
|
||||||
|
content = f"""from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class {name.capitalize()}Config(AppConfig):
|
||||||
|
name = '{name}'
|
||||||
|
verbose_name = "{name}App"
|
||||||
|
"""
|
||||||
|
with open(os.path.join(app_path, "apps.py"), 'w', encoding='UTF-8') as f:
|
||||||
|
f.write(content)
|
||||||
|
f.close()
|
||||||
|
# 注册app到 settings.py 中
|
||||||
|
injection(os.path.join(BASE_DIR, "application", "settings.py"), f" 'apps.{name}',\n", "INSTALLED_APPS",
|
||||||
|
"]")
|
||||||
|
|
||||||
|
# 注册app到 urls.py 中
|
||||||
|
injection(os.path.join(BASE_DIR, "application", "urls.py"),
|
||||||
|
f" re_path(r'^{name}/', include('apps.{name}.urls')),\n", "urlpatterns = [",
|
||||||
|
"]")
|
||||||
|
|
||||||
|
print(f"创建 {name} App成功")
|
||||||
|
|
||||||
|
|
||||||
|
def injection(file_path, insert_content, startswith, endswith):
|
||||||
|
with open(file_path, "r+", encoding="utf-8") as f:
|
||||||
|
data = f.readlines()
|
||||||
|
with open(file_path, 'w', encoding='UTF-8') as f1:
|
||||||
|
is_INSTALLED_APPS = False
|
||||||
|
is_insert = False
|
||||||
|
for content in data:
|
||||||
|
# 判断文件是否 INSTALLED_APPS 开头
|
||||||
|
if not is_insert and content.startswith(startswith):
|
||||||
|
is_INSTALLED_APPS = True
|
||||||
|
if not is_insert and content.startswith(endswith) and is_INSTALLED_APPS:
|
||||||
|
# 给前一行插入数据
|
||||||
|
content = insert_content + content
|
||||||
|
is_insert = True
|
||||||
|
f1.writelines(content)
|
|
@ -29,7 +29,7 @@ def get_object_or_404(queryset, *filter_args, **filter_kwargs):
|
||||||
|
|
||||||
class GenericViewSet(ViewSetMixin, GenericAPIView):
|
class GenericViewSet(ViewSetMixin, GenericAPIView):
|
||||||
extra_filter_backends = []
|
extra_filter_backends = []
|
||||||
pagination_class = Pagination
|
pagination_class = api_settings.DEFAULT_PAGINATION_CLASS
|
||||||
filter_backends = [DjangoFilterBackend, OrderingFilter, SearchFilter, AdvancedSearchFilter]
|
filter_backends = [DjangoFilterBackend, OrderingFilter, SearchFilter, AdvancedSearchFilter]
|
||||||
view_logger_classes = (CustomerModelViewLogger,)
|
view_logger_classes = (CustomerModelViewLogger,)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
"""
|
"""
|
||||||
项目初始化命令: python manage.py initialization
|
项目初始化命令: python manage.py init
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def customSql(self, sql_list, model_name, table_name, is_yes):
|
def customSql(self, sql_list, model_name, table_name, is_yes):
|
||||||
|
|
|
@ -235,7 +235,7 @@ class UserProfileSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = UserProfile
|
model = UserProfile
|
||||||
depth = 1
|
depth = 1
|
||||||
exclude = ('password', 'secret', 'user_permissions', 'groups', 'is_superuser', 'date_joined')
|
exclude = ('password', 'secret', 'user_permissions', 'groups', 'is_superuser', 'date_joined', 'creator')
|
||||||
|
|
||||||
|
|
||||||
class ExportUserProfileSerializer(CustomModelSerializer):
|
class ExportUserProfileSerializer(CustomModelSerializer):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class PermissionConfig(AppConfig):
|
class SystemConfig(AppConfig):
|
||||||
name = 'vadmin.system'
|
name = 'vadmin.system'
|
||||||
verbose_name = "权限管理"
|
verbose_name = "系统管理"
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateConfig(AppConfig):
|
||||||
|
name = 'vadmin.template'
|
||||||
|
verbose_name = "模板App"
|
|
@ -0,0 +1,2 @@
|
||||||
|
# from ..models.xxx import Xxx
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
|
@ -0,0 +1 @@
|
||||||
|
urlpatterns = []
|
Loading…
Reference in New Issue