Beispiel #1
0
                         is_active=True,
                         is_superuser=True)
        logger.info('创建admin用户成功!')
    else:
        logger.info('已有用户,无需创建admin')

except Exception as e:
    logger.error('程序异常 --> [%s]' % str(e))

# 初始化用户组对象
try:
    for item_dict in USER_GROUP_LIST:
        key = item_dict['k']
        value = item_dict['v']
        if len(UserGroup.objects(key=key)) == 0:
            group = UserGroup()
            group.key = key
            group.value = value
            group.save()
    logger.info('初始化用户组成功!')
except Exception as e:
    logger.error('初始化用户组异常![%s]' % e.message)

# 初始化菜单对象
try:
    for menu_item in MENU_LIST:
        main_menu = menu_item['main']
        if not Menu.objects(
                type=MENU_MAIN, p_key=main_menu[2], c_key=main_menu[3]):
            Menu.gen_new_menu(main_menu[0], main_menu[1], main_menu[2],
                              main_menu[3], main_menu[4])