Ejemplo n.º 1
0
def managerCreateWeixinMenu(request):
    result,loginUser = LoginStatus(ltoken=get_token(request))
    if not result:
        infor = loginUser
        return JsonResponse(GlobalVar.RspOffLine,infor)
    
    if not (u'管理员' in loginUser.Role):
        return JsonResponse(GlobalVar.RspFail,'需要管理员权限')
    
    if request.method == 'POST':
        #如果是Json格式的菜单,解析出来
        _strReq = request.body
        result,msg = False,''
        if len(_strReq) == 0:
            debug('views_weixin.py->managerCreateWeixinMenu->mod:','create without json para') 
            result,msg = creat_menu()
        else:
            debug('views_weixin.py->managerCreateWeixinMenu->mod:','create with json para') 
            result,msg = creat_menu(_strReq)
            
        if result:
            return JsonResponse(GlobalVar.RspSuccess,msg)
        else:
            return JsonResponse(GlobalVar.RspFail,msg)
    elif request.method == 'GET':
        type = request.GET.get('type','')
        #删除所有
        if type == 'delete':
            result,msg = delete_menu()
            if result:
                return JsonResponse(GlobalVar.RspSuccess,msg)
            else:
                return JsonResponse(GlobalVar.RspFail,msg)
        else:
            return JsonResponse(GlobalVar.RspSuccess,'该方法未定义')
    else:
        return JsonResponse(GlobalVar.RspSuccess,'Other Method is building')
Ejemplo n.º 2
0
def Weixin_User_Grouop(request):
    result,loginUser = LoginStatus(ltoken=get_token(request))
    if not result:
        infor = loginUser
        return JsonResponse(GlobalVar.RspOffLine,infor)
    
    if not (u'管理员' in loginUser.Role):
        return JsonResponse(GlobalVar.RspFail,'只能管理员才能管理用户群组')
    
    if request.method == 'POST':
        #POST方法创建用户群组
        _strReq = request.body
        result,msg = False,''
        if len(_strReq) == 0:
            print 'Weixin_User_Grouop:create without json para'
            result,msg = creat_user_group()
        else:
            print 'Weixin_User_Grouop:create with json para'
            result,msg = creat_user_group(_strReq)
            
        if result:
            return JsonResponse(GlobalVar.RspSuccess,msg)
        else:
            return JsonResponse(GlobalVar.RspFail,msg)
    elif request.method == 'GET':
        type = request.GET.get('type','')
        #删除所有
        if type == 'delete':
            result,msg = delete_menu()
            if result:
                return JsonResponse(GlobalVar.RspSuccess,msg)
            else:
                return JsonResponse(GlobalVar.RspFail,msg)
        else:
            return JsonResponse(GlobalVar.RspSuccess,'该方法未定义')
    else:
        return JsonResponse(GlobalVar.RspSuccess,'Other Method is building')