コード例 #1
0
ファイル: menu.py プロジェクト: liangpz521/cbms
def edit(request):
    if request.method == "POST":
	parentid = request.POST['parentid']
	name = request.POST['name']
	m = request.POST.get('m','')
	c = request.POST.get('c','')
	a = request.POST.get('a','')
	id = request.POST.get('id')
	data = request.POST.get('data','')
	display = request.POST.get('display')
	try:
	    obj = Menu.objects.get(id=id)
	    obj.parentid = parentid
	    obj.name = name;
	    obj.m = m
	    obj.c = c
	    obj.a = a
	    obj.data = data
	    obj.display = display
	    obj.save()
	    return showmessage(request,"编辑菜单成功",'/admin/menu/init/',3000)
	except:
	    return showmessage(request,"系统参数错误,无法编辑",'/admin/menu/init/',3000)
    else:
	menuid = request.GET.get('id')
	menuinfo = Menu.objects.get(id=menuid)
	listinfo = Menu.objects.all().order_by('listorder','-id')
	t = Tree()
	t.arr = listinfo
	info = t.get_tree(0,'')
	return render_to_response('admin/menu/menu_edit.html',{'menulist':info,'menuinfo':menuinfo})
コード例 #2
0
ファイル: menu.py プロジェクト: liangpz521/cbms
def init(request):
    listinfo = Menu.objects.all().order_by('listorder','-id')
    t = Tree()
    t.icon = ('   │ ','   ├─ ','   └─ ')
    t.nbsp = '   '
    t.arr = listinfo
    info = t.get_tree(0,'')
    return render_to_response('admin/menu/init.html',{'menulist':info})
コード例 #3
0
ファイル: role.py プロジェクト: liangpz521/cbms
def role_priv(request):
    if request.method == "POST":
        info = dict(request.POST)
	Rinfo = ''
	if 'menuid[]' in info:
	    Rinfo = info['menuid[]']
	roleid = request.POST.get('roleid')
	siteid = request.POST.get('siteid')
	menuinfo = Menu.objects.all().values('id','m','a','c','data')
    
	list_info = {}
	for item in menuinfo:
	    kid =item['id']
	    list_info[kid] = item
	M = Rolecat()
	if len(Rinfo) > 0:
	    try:
		RolePriv.objects.filter(roleid=roleid,siteid=siteid).delete()
	    except:
		print 'no data delete'
		pass
	    for val in Rinfo:
		val = int(val)
		da = M.get_menuinfo(val,list_info)
		RolePriv.objects.create(roleid=roleid,m=da['m'],c=da['c'],a=da['a'],siteid=siteid,
		                        data=da['data'],menuid=da['id'])
	else:
	    try:
		RolePriv.objects.filter(roleid=roleid,siteid=siteid).delete()
	    except:
		pass
	return showmessage(request,"操作成功");
    else:
	roleid = int(request.GET.get('roleid',0))
	catid = request.GET.get('catid',0)
	rolearr = RolePriv.objects.filter(roleid=roleid)
	result = Menu.objects.all()
	m = Rolecat()
	menuarr =[]
	info = ''
	for item in result:
	    listinfo = {}
	    listinfo['id'] = item.id
	    listinfo['parentid'] = item.parentid
	    listinfo['name'] = item.name
	    listinfo['checked'] = m.is_checked(item,roleid,1,rolearr);
	    listinfo['parentid_node'] = "class='child-of-node-%s'" % item.parentid if item.parentid else ''
	    listinfo['level'] = m.get_level(item.id,result);
	    menuarr.append(listinfo)
    
	t = Tree()
	t.icon = ('│ ','├─ ','└─ ')
	t.nbsp = '   '
	t.arr = menuarr
	info = t.get_tree2(0,'')
	siteid = request.GET.get('siteid','')
	return render_to_response('admin/role_priv.html',{'plist':info,'siteid':siteid,
	                'roleid':roleid,'catid':catid})
コード例 #4
0
ファイル: menu.py プロジェクト: liangpz521/cbms
def add(request):
    if request.method == "POST":
	parentid = request.POST['parentid']
	name = request.POST['name']
	m = request.POST.get('m','')
	c = request.POST.get('c','')
	a = request.POST.get('a','')
	data = request.POST.get('data','')
	display = request.POST.get('display',1)
	obj = Menu.objects.create(name=name,parentid=parentid,m=m,a=a,c=c,
	                          data=data,display=display,listorder=0)
	return showmessage(request,"添加菜单成功",'/admin/menu/init/',2000)
    else:
	parentid = int(request.GET.get('parentid',0))
	listinfo = Menu.objects.all().order_by('listorder','-id')
	t = Tree()
	t.arr = listinfo
	info = t.get_tree(0,'')
	return render_to_response('admin/menu/menu_add.html',{'menulist':info,'pid':parentid})
コード例 #5
0
ファイル: menu.py プロジェクト: liangpz521/cbms
def role(request):
    roleid = request.session.get('roleid')
    roleid = 4
    rolearr = RolePriv.objects.filter(roleid=roleid)
    result = Menu.objects.all()
    m = Rolecat()
    menuarr =[]
    info = ''
    for item in result:
        listinfo = {}
	listinfo['id'] = item.id
	listinfo['parentid'] = item.parentid
        listinfo['name'] = item.name
        listinfo['checked'] = m.is_checked(item,roleid,1,rolearr);
	listinfo['parentid_node'] = "class='child-of-node-%s'" % item.parentid if item.parentid else ''
	listinfo['level'] = m.get_level(item.id,result);
        menuarr.append(listinfo)
    t = Tree()
    t.icon = ('│ ','├─ ','└─ ')
    t.nbsp = '   '
    t.arr = menuarr
    info = t.get_tree2(0,'')
    return render_to_response('temp.html',{'plist':info})
コード例 #6
0
ファイル: menu.py プロジェクト: liangpz521/cbms
def menulist(request):
    listinfo = Menu.objects.all().order_by('listorder','-id')
    t = Tree()
    t.arr = listinfo
    info = t.get_tree(0,'')
    return render_to_response('temp.html',{'menulist':info})