def rightgiveuser(req):
    if not req.session.get("sess_userid", False):
        return HttpResponseRedirect("/login/")
    else:
        nUrldata = req.path
        nRightUserid = req.session["sess_userid"]
        nHaveRight = Right.userrightcheck(nRightUserid, nUrldata)
        if nHaveRight[0]["num"] == 0:
            return HttpResponseRedirect("/noright/")
        else:
            if req.method == 'GET':
                nRightuserid = req.GET['userid']
                userinfo = Right.getrightusers(nRightuserid)
                data = Right.getallright(nRightuserid)
                return render_to_response('right/right-giveuser.html', {'data': data, 'datas': userinfo})
            else:
                nUserid = req.session["sess_userid"]
                nRightidList = req.POST.get('rightsid')
                nRightuserName= req.POST.get('username')
                print nRightuserName
                nRightuserId = User.getUserIdbyUsername(nRightuserName)
                print "nRightuserId="
                print nRightuserId

                Right.userrightupdate(nRightuserId,nRightidList)
                return HttpResponseRedirect('/user/userlist/')
def rightlist(req):
    if not req.session.get("sess_userid", False):
        return HttpResponseRedirect("/login/")
    else:
        nUrldata = req.path
        nRightUserid = req.session["sess_userid"]
        nHaveRight = Right.userrightcheck(nRightUserid, nUrldata)
        if nHaveRight[0]["num"] == 0:
            return HttpResponseRedirect("/noright/")
        else:
            nRightuserid = 0
            userinfo = Right.getrightusers(nRightuserid)
            userlen = len(userinfo)
            datalist = Right.rightlist()
            return render_to_response('right/right-list.html', {'data': datalist, 'datas': userlen})