def add_app_by_children(appchildren, filegroup): """ 保存应用子节点 by:王健 at:2015-1-12 修改Model名字,去除下划线,index改为sorted by:王健 at:2015-1-13 应用节点icon_url 字段 by:王健 at:2015-1-28 :param appchildren: :param filegroup: :return: """ index = 1 for app in appchildren: if not FileGroup.objects.filter(flag=app.get('flag')).exists(): fgroup = FileGroup() else: fgroup = FileGroup.objects.get(flag=app.get('flag')) fgroup.flag = app.get('flag') fgroup.name = app.get('name') fgroup.icon = app.get('icon') # fgroup.icon_url = '/static/icon/%s' % app.get('icon') fgroup.typeflag = app.get('typeflag') fgroup.sorted = index index += 1 fgroup.father = filegroup fgroup.status = 'sys' fgroup.save() if app.has_key('children'): add_app_by_children(app['children'], fgroup)
def add_default_app(**kwargs): """ 保存应用节点,初始化项目使用 by:王健 at:2015-1-12 修改Model名字,去除下划线,index改为sorted by:王健 at:2015-1-13 初始化时,添加测试数据 by:王健 at:2015-1-20 应用节点icon_url 字段 by:王健 at:2015-1-28 初始化 第一个用户 id 自10000起, 失败,直接修改数据库 by:王健 at:2015-3-6 数据初始化只在第一次运行 by: 范俊伟 at:2015-06-29 :param kwargs: :return: """ if FileGroup.objects.all().count() == 0: index = 1 for app in appitem['children']: if not FileGroup.objects.filter(flag=app.get('flag')).exists(): fgroup = FileGroup() else: fgroup = FileGroup.objects.get(flag=app.get('flag')) fgroup.flag = app.get('flag') fgroup.name = app.get('name') fgroup.icon = app.get('icon') # fgroup.icon_url = '/static/icon/%s' % app.get('icon') fgroup.typeflag = app.get('typeflag') fgroup.sorted = index index += 1 fgroup.status = 'sys' fgroup.save() if app.has_key('children'): add_app_by_children(app['children'], fgroup) if Project.objects.all().count() == 0: test_data_insert()