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})
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})
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})