コード例 #1
0
def getSkuAnalyticsInfo(request):

    sku_id = -9999
    ret = {}
    try:
        sku_id = int(request.GET['sku_id'])
        ret = sku_service.getSingleSku_Mixed_Info(sku_id)
    except:
        print("Invalid request: sku_id error, sku_id requested is (-9999 means none) : %s" %sku_id)

    resp = jsonHelper.getJSONPStr(request,ret)
    return HttpResponse(resp, content_type="application/json")
コード例 #2
0
def getCategoryListAll(request):

    level = 1
    try:
        level = int(request.GET['level'])
    except:
        print("request param: level: incorrect")
        pass

    # ret = category_service.getServiceCategoryListAll(level)
    ret = catalog_service.getCatalogs()
    resp = jsonHelper.getJSONPStr(request, ret)
    return HttpResponse(resp, content_type="application/json")
コード例 #3
0
def getCategoryListAll(request):

    level = 1
    try:
        level = int(request.GET['level'])
    except:
        print("request param: level: incorrect")
        pass

    # ret = category_service.getServiceCategoryListAll(level)
    ret = catalog_service.getCatalogs()
    resp = jsonHelper.getJSONPStr(request,ret)
    return HttpResponse(resp, content_type="application/json")
コード例 #4
0
def getQueryIndicator(request):

    ret = {
        'category': [],
        'property': [],
    }
    try:
        query = request.GET['query']
        #print(len(query))
        #print "lenquery"
        if len(query)>=2:
            ret = catalog_service.get_indicator_given_part_of_query(query)
    except:
        pass
    resp = jsonHelper.getJSONPStr(request,ret)
    return HttpResponse(resp, content_type="application/json")
コード例 #5
0
def getQueryIndicator(request):

    ret = {
        'category': [],
        'property': [],
    }
    try:
        query = request.GET['query']
        #print(len(query))
        #print "lenquery"
        if len(query) >= 2:
            ret = catalog_service.get_indicator_given_part_of_query(query)
    except:
        pass
    resp = jsonHelper.getJSONPStr(request, ret)
    return HttpResponse(resp, content_type="application/json")
コード例 #6
0
def getUserListHistory(request):

    ret = {
        'query':[],
        'catalog':[],
    }
    if 'device_id' in request.GET:
        device_id = request.GET['device_id']
    else:
        device_id = client_uuid.getClientUUID(request)

    if device_id is not None:
        ret['query'] = user_history_service.getQueryHistory(device_id)
        ret['catalog'] = user_history_service.getCatalogHistory(device_id)

    resp = jsonHelper.getJSONPStr(request,ret)
    return HttpResponse(resp, content_type="application/json")
コード例 #7
0
def record_device(request):

    ret = {
        'status': -1,
        'msg': 'bad request',
    }

    try:
        original_device_id = request.GET['device_id']
        device_id = original_device_id.strip()
        device_id = device_id[1:len(device_id)-1].replace(' ','')
        platform = request.GET['platform']
        fnret = apns_service.record_device_id(deviceid=device_id, platform=platform, original_deviceid=original_device_id)
        ret['status'] = 0
        ret['msg'] = 'ok'
    except:
        pass

    resp = jsonHelper.getJSONPStr(request,ret)
    return HttpResponse(resp, content_type="application/json")
コード例 #8
0
def record_device(request):

    ret = {
        'status': -1,
        'msg': 'bad request',
    }

    try:
        original_device_id = request.GET['device_id']
        device_id = original_device_id.strip()
        device_id = device_id[1:len(device_id) - 1].replace(' ', '')
        platform = request.GET['platform']
        fnret = apns_service.record_device_id(
            deviceid=device_id,
            platform=platform,
            original_deviceid=original_device_id)
        ret['status'] = 0
        ret['msg'] = 'ok'
    except:
        pass

    resp = jsonHelper.getJSONPStr(request, ret)
    return HttpResponse(resp, content_type="application/json")
コード例 #9
0
def getDiscountItemsAll(request):

    startpos = 0
    try:
        startpos = int(request.GET['startpos'])
    except:
        # FRAME is SET TO 0
        pass

    category_id = "_ALL_"
    min_price = min_discount_rate = None
    try:
        category_id = request.GET['category_id']
        print "ok, cateid = %s" % category_id
        min_price = float(request.GET['min_price'])
        min_discount_rate = float(request.GET['max_discount_rate'])
        category_id = request.GET['category_id']
        print "ok, cateid = %s" % category_id
    except:
        pass

    querykw = None
    try:
        querykw = request.GET['query']
        # print "query = %s" %querykw
    except:
        pass

    device_id = "_DEFAULT_ID_"
    try:
        device_id = request.GET['device_id']
    except:
        pass

    ip = '0.0.0.0'
    try:
        if request.META.has_key('HTTP_X_FORWARDED_FOR'):
            ip = request.META['HTTP_X_FORWARDED_FOR']
        else:
            ip = request.META['REMOTE_ADDR']
    except:
        pass

    need_set_cookie = False
    if device_id == "_DEFAULT_ID_":
        device_id = client_uuid.getClientUUID(request)
        need_set_cookie = True

    ret = None

    use_query = False
    if querykw is not None:
        if len(querykw.strip()) > 1:
            use_query = True
            query2 = querykw.replace('"', '').replace("'",
                                                      '').replace('OR', ' ')
            ret = sku_service.getSkuListByQuery(query2, startpos)

            # record event
            user_logging_service.log_user_event_with_thread(
                device_id, querykw, '', ip)
    print "here1"
    if not use_query:
        ret = sku_service.getSkuListByCatalogID(category_id, startpos)
        print 'here222'
        user_logging_service.log_user_event_with_thread(device_id,
                                                        query='',
                                                        catalog_id=category_id,
                                                        remote_ip=ip)
        print 'here333'

    resp = jsonHelper.getJSONPStr(request, ret)
    response = HttpResponse(resp, content_type="application/json")
    if need_set_cookie:
        response.set_cookie(client_uuid.UUID_COOKIE_NAME, device_id)
    return response
コード例 #10
0
ファイル: commons.py プロジェクト: denniszhoujian/worthyback
def getServerDomain(request):

    ret = data_config.SERVER_DOMAIN
    resp = jsonHelper.getJSONPStr(request,ret)
    return HttpResponse(resp, content_type="application/json")
コード例 #11
0
def getDiscountItemsAll(request):

    startpos = 0
    try:
        startpos = int(request.GET['startpos'])
    except:
        # FRAME is SET TO 0
        pass

    category_id = "_ALL_"
    min_price = min_discount_rate = None
    try:
        category_id = request.GET['category_id']
        print "ok, cateid = %s" %category_id
        min_price = float(request.GET['min_price'])
        min_discount_rate = float(request.GET['max_discount_rate'])
        category_id = request.GET['category_id']
        print "ok, cateid = %s" %category_id
    except:
        pass


    querykw = None
    try:
        querykw = request.GET['query']
        # print "query = %s" %querykw
    except:
        pass

    device_id = "_DEFAULT_ID_"
    try:
        device_id = request.GET['device_id']
    except:
        pass

    ip = '0.0.0.0'
    try:
        if request.META.has_key('HTTP_X_FORWARDED_FOR'):
            ip =  request.META['HTTP_X_FORWARDED_FOR']
        else:
            ip = request.META['REMOTE_ADDR']
    except:
        pass

    need_set_cookie = False
    if device_id == "_DEFAULT_ID_":
        device_id = client_uuid.getClientUUID(request)
        need_set_cookie = True

    ret = None

    use_query = False
    if querykw is not None:
        if len(querykw.strip())>1:
            use_query = True
            query2 = querykw.replace('"','').replace("'",'').replace('OR',' ')
            ret = sku_service.getSkuListByQuery(query2,startpos)

            # record event
            user_logging_service.log_user_event_with_thread(device_id,querykw,'',ip)
    print "here1"
    if not use_query:
        ret = sku_service.getSkuListByCatalogID(category_id,startpos)
        print 'here222'
        user_logging_service.log_user_event_with_thread(device_id,query='',catalog_id=category_id,remote_ip = ip)
        print 'here333'

    resp = jsonHelper.getJSONPStr(request,ret)
    response = HttpResponse(resp, content_type="application/json")
    if  need_set_cookie:
        response.set_cookie(client_uuid.UUID_COOKIE_NAME,device_id)
    return response
コード例 #12
0
ファイル: commons.py プロジェクト: denniszhoujian/worthyback
def getServerDomain(request):

    ret = data_config.SERVER_DOMAIN
    resp = jsonHelper.getJSONPStr(request, ret)
    return HttpResponse(resp, content_type="application/json")