性能提升(用户管理): 支持重写用户模型
1. 在settings.py 中 AUTH_USER_MODEL 为重写的 user位置 2. 继承 from apps.vadmin.permission.models import UserProfile 写自己的用户模型 3. 需要注意,自己重写的用户模型不能有必填字段pull/21/head
parent
6f1c26061a
commit
fcd6e85ea6
|
@ -9,7 +9,7 @@ class Monitor(CoreModel):
|
|||
mem_num = CharField(max_length=32, verbose_name='内存总数(KB)')
|
||||
mem_sys = CharField(max_length=32, verbose_name='内存已使用大小(KB)')
|
||||
seconds = CharField(max_length=32, verbose_name='系统已运行时间')
|
||||
server = ForeignKey(to='Server', on_delete=CASCADE, verbose_name="关联服务器信息", db_constraint=False)
|
||||
server = ForeignKey(to='monitor.Server', on_delete=CASCADE, verbose_name="关联服务器信息", db_constraint=False)
|
||||
|
||||
class Meta:
|
||||
verbose_name = '服务器监控信息'
|
||||
|
|
|
@ -9,7 +9,7 @@ class SysFiles(CoreModel):
|
|||
type_name = CharField(max_length=32, verbose_name='盘符类型')
|
||||
total = CharField(max_length=32, verbose_name='磁盘总大小(KB)')
|
||||
disk_sys = CharField(max_length=32, verbose_name='已使用大小(KB)')
|
||||
monitor = ForeignKey(to='Monitor', on_delete=CASCADE, verbose_name="关联服务器监控信息", db_constraint=False)
|
||||
monitor = ForeignKey(to='monitor.Monitor', on_delete=CASCADE, verbose_name="关联服务器监控信息", db_constraint=False)
|
||||
|
||||
class Meta:
|
||||
verbose_name = '系统磁盘'
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import connection
|
||||
|
||||
|
@ -75,6 +76,7 @@ class Command(BaseCommand):
|
|||
parser.add_argument('-N', nargs='*')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
user_name = "_".join(settings.AUTH_USER_MODEL.lower().split("."))
|
||||
init_dict = {
|
||||
'system_dictdata': [os.path.join('system', 'system_dictdata.sql'), '字典管理', 'system_dictdata'],
|
||||
'system_dictdetails': [os.path.join('system', 'system_dictdetails.sql'), '字典详情', 'system_dictdetails'],
|
||||
|
@ -86,8 +88,7 @@ class Command(BaseCommand):
|
|||
'permission_role': [os.path.join('permission', 'permission_role.sql'), '角色管理',
|
||||
','.join(['permission_role', 'permission_role_dept', 'permission_role_menu'])],
|
||||
'permission_userprofile': [os.path.join('permission', 'permission_userprofile.sql'), '用户管理', ','.join(
|
||||
['permission_userprofile_groups', 'permission_userprofile', 'permission_userprofile_role',
|
||||
'permission_userprofile_post'])]
|
||||
[f'{user_name}_groups', f'{user_name}', f'{user_name}_role', f'{user_name}_post'])]
|
||||
}
|
||||
init_name = options.get('init_name')
|
||||
is_yes = None
|
||||
|
|
|
@ -11,7 +11,7 @@ class Dept(CoreModel):
|
|||
phone = CharField(max_length=32, verbose_name="联系电话", null=True, blank=True)
|
||||
email = CharField(max_length=32, verbose_name="邮箱", null=True, blank=True)
|
||||
status = CharField(max_length=8, verbose_name="部门状态", null=True, blank=True)
|
||||
parentId = ForeignKey(to='Dept', on_delete=CASCADE, default=False, verbose_name="上级部门",
|
||||
parentId = ForeignKey(to='permission.Dept', on_delete=CASCADE, default=False, verbose_name="上级部门",
|
||||
db_constraint=False, null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -18,8 +18,8 @@ class Role(CoreModel):
|
|||
admin = BooleanField(default=False, verbose_name="是否为admin")
|
||||
dataScope = CharField(max_length=8,default='1', choices=DATASCOPE_CHOICES, verbose_name="权限范围",)
|
||||
remark = TextField(verbose_name="备注", help_text="备注", null=True, blank=True)
|
||||
dept = ManyToManyField(to='Dept', verbose_name='数据权限-关联部门', db_constraint=False)
|
||||
menu = ManyToManyField(to='Menu', verbose_name='关联菜单权限', db_constraint=False)
|
||||
dept = ManyToManyField(to='permission.Dept', verbose_name='数据权限-关联部门', db_constraint=False)
|
||||
menu = ManyToManyField(to='permission.Menu', verbose_name='关联菜单权限', db_constraint=False)
|
||||
|
||||
class Meta:
|
||||
verbose_name = '角色管理'
|
||||
|
|
|
@ -23,9 +23,9 @@ class UserProfile(AbstractUser, CoreModel):
|
|||
gender = CharField(max_length=8, verbose_name="性别", null=True, blank=True)
|
||||
remark = TextField(verbose_name="备注", null=True)
|
||||
user_type = IntegerField(default=0, verbose_name="用户类型")
|
||||
post = ManyToManyField(to='Post', verbose_name='关联岗位', db_constraint=False)
|
||||
role = ManyToManyField(to='Role', verbose_name='关联角色', db_constraint=False)
|
||||
dept = ForeignKey(to='Dept', verbose_name='归属部门', on_delete=CASCADE, db_constraint=False, null=True, blank=True)
|
||||
post = ManyToManyField(to='permission.Post', verbose_name='关联岗位', db_constraint=False)
|
||||
role = ManyToManyField(to='permission.Role', verbose_name='关联角色', db_constraint=False)
|
||||
dept = ForeignKey(to='permission.Dept', verbose_name='归属部门', on_delete=CASCADE, db_constraint=False, null=True, blank=True)
|
||||
|
||||
@property
|
||||
def get_user_interface_dict(self):
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def getSql(filename):
|
||||
"""
|
||||
|
@ -9,6 +11,10 @@ def getSql(filename):
|
|||
"""
|
||||
abspath = os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
|
||||
pwd = os.path.join(abspath, 'scripts', filename)
|
||||
with open(pwd,'rb') as fp:
|
||||
with open(pwd, 'rb') as fp:
|
||||
content = fp.read().decode('utf8')
|
||||
if filename == "permission/permission_userprofile.sql":
|
||||
user_name = "_".join(settings.AUTH_USER_MODEL.lower().split("."))
|
||||
content = content.replace("permission_userprofile", user_name). \
|
||||
replace("userprofile", settings.AUTH_USER_MODEL.lower().split(".")[-1])
|
||||
return [ele for ele in content.split('\n') if not ele.startswith('--') and ele.strip(' ')]
|
||||
|
|
|
@ -9,7 +9,7 @@ class DictDetails(CoreModel):
|
|||
is_default = BooleanField(verbose_name="是否默认", default=False)
|
||||
status = CharField(max_length=2, verbose_name="字典状态")
|
||||
sort = CharField(max_length=256, verbose_name="字典排序")
|
||||
dict_data = ForeignKey(to='DictData', on_delete=CASCADE, verbose_name="关联字典", db_constraint=False)
|
||||
dict_data = ForeignKey(to='system.DictData', on_delete=CASCADE, verbose_name="关联字典", db_constraint=False)
|
||||
remark = CharField(max_length=256, verbose_name="备注", null=True, blank=True)
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue