def local(request):

    lat, lng, start, count, language_code, cuid, new_client = get_client_info(request)

    client = Clients.get_client_by_cuid(session=DBSession, cuid=cuid, lat=lat, lng=lng)

    Clients.check_in(session=DBSession, cuid=cuid, lat=lat, lng=lng)

    posts = client_utils.get_approved_posts(
        client_id=client.client_id, language_code=language_code, lat=lat, lng=lng, start=start, count=count
    )

    return {"new_client": new_client, "cuid": cuid, "client": client, "lat": lat, "lng": lng, "posts": posts}
示例#2
0
def get_local_posts(request):

    result = {'success': False}
    status_code = 200

    #try:
    if True:
        success, error_text, language_code, lat, lng, \
            client = client_utils.register_client(request)
        if success == False:
            raise Exception(error_text)

        try:
            start = 0
            if 'start' in request.GET:
                start = int(float(request.GET['start']))
            count = 75
            if 'count' in request.GET:
                count = int(float(request.GET['count']))
        except:
            status_code = 403
            raise Exception("Invalid input.")

        posts = client_utils.get_approved_posts(
            client_id = client.client_id,
            language_code = language_code,
            lat = lat,
            lng = lng,
            start = start,
            count = count,
        )

        result['posts'] = posts
        result['success'] = True

    #except Exception, e:
    #    status_code = 400
    #    result['error_text'] = str(e)

    client_utils.log_client_action(
        client = client,
        url = 'get_approved_posts.json',
        lat = lat,
        lng = lng,
        request = request,
        result = result,
        success = success,
    )

    return utils.make_response(result, status_code)
示例#3
0
def get_local_posts(request):

    result = {'success': False}
    status_code = 200

    #try:
    if True:
        success, error_text, language_code, lat, lng, \
            client = client_utils.register_client(request)
        if success == False:
            raise Exception(error_text)

        try:
            start = 0
            if 'start' in request.GET:
                start = int(float(request.GET['start']))
            count = 75
            if 'count' in request.GET:
                count = int(float(request.GET['count']))
        except:
            status_code = 403
            raise Exception("Invalid input.")

        posts = client_utils.get_approved_posts(
            client_id=client.client_id,
            language_code=language_code,
            lat=lat,
            lng=lng,
            start=start,
            count=count,
        )

        result['posts'] = posts
        result['success'] = True

    #except Exception, e:
    #    status_code = 400
    #    result['error_text'] = str(e)

    client_utils.log_client_action(
        client=client,
        url='get_approved_posts.json',
        lat=lat,
        lng=lng,
        request=request,
        result=result,
        success=success,
    )

    return utils.make_response(result, status_code)
示例#4
0
def local(request):

    lat, lng, start, count, language_code, cuid, new_client = get_client_info(
        request)

    client = Clients.get_client_by_cuid(
        session=DBSession,
        cuid=cuid,
        lat=lat,
        lng=lng,
    )

    Clients.check_in(
        session=DBSession,
        cuid=cuid,
        lat=lat,
        lng=lng,
    )

    posts = client_utils.get_approved_posts(
        client_id=client.client_id,
        language_code=language_code,
        lat=lat,
        lng=lng,
        start=start,
        count=count,
    )

    return {
        'new_client': new_client,
        'cuid': cuid,
        'client': client,
        'lat': lat,
        'lng': lng,
        'posts': posts
    }