示例#1
0
def stories(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,
    )

    stories = client_utils.get_stories(
        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,
        'stories': stories
    }
def stories(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)

    stories = client_utils.get_stories(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, "stories": stories}
示例#3
0
def get_stories(request):

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

    try:
        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 = 25
            if 'count' in request.GET:
                count = int(float(request.GET['count']))
                if count > 25:
                    # limit the number of stories returned to 25 at a time to 
                    # reduce load on the server
                    count = 25
        except:
           status_code = 403
           raise Exception("Invalid input.") 

        stories = client_utils.get_stories(
            language_code = language_code,
            lat = lat,
            lng = lng,
            start = start,
            count = count,
        )

        result['stories'] = stories
        result['success'] = True

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