Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)