Ejemplo n.º 1
0
def get_users(request) :
    limit, offset = get_paginate_info(request.GET)
    session = get_session()
    users = session.query(UserInfo).limit(limit).offset(offset).all()
    session.close()
    
    data = dict(
        user_list = to_dict(users),
        )
    result = dict(success=True, message=u'users.views.get_users: user list from {start} to {end}'.format(start=offset, end=limit+offset), data=data, start=offset, end=limit+offset)
    return HttpResponse(dumps(result, True))
Ejemplo n.º 2
0
def get_images(request):
    limit, offset = get_paginate_info(request.GET)
    session = get_session()
    image_id_list = session.query(Image.image_id).limit(limit).offset(offset).all()
    session.close()
    image_id_list = [ y for x in image_id_list for y in x ]

    data = dict(
        image_list = image_id_list 
        )
    result = dict(success=True, message=u'images.views.get_images: images from {start} to {end}'.format(start=offset, end=offset+limit), data=data)
    return HttpResponse(dumps(result))
Ejemplo n.º 3
0
def get_spot_snaps(request, spot_id=None):
    limit, offset = get_paginate_info(request.GET)
    session = get_session()
    snaps = session.query(Snap).filter_by(spot_id=spot_id).limit(limit).offset(offset).all()

    data = dict(snap_list=to_dict(snaps))

    session.close()
    result = dict(
        success=True,
        message=u"spots.views.get_spot_snaps: snaps from {start} to {end}".format(start=offset, end=offset + limit),
        data=data,
    )
    return HttpResponse(dumps(result))
Ejemplo n.º 4
0
def get_spot_users(request, spot_id=None):
    limit, offset = get_paginate_info(request.GET)

    session = get_session()

    SpotUserAssociation.relations.append("userinfo")
    spot_user_list = session.query(SpotUserAssociation).filter_by(spot_id=spot_id).limit(limit).offset(offset).all()

    data = dict(spot_user_list=to_dict(spot_user_list))
    session.close()
    result = dict(
        success=True, message=u"spots.views.get_spot_users: spot {spot_id} user list".format(spot_id=spot_id), data=data
    )
    return HttpResponse(dumps(result))
Ejemplo n.º 5
0
def get_spot_list(request):
    limit, offset = get_paginate_info(request.GET)

    session = get_session()
    spot_list = session.query(Spot).limit(limit).offset(offset).all()
    data = dict(spot_list=to_dict(spot_list))

    session.close()
    result = dict(
        success=True,
        message=u"spots.views.get_spot_list: the list of spots from {start} to {end}".format(
            start=offset, end=offset + limit
        ),
        data=data,
    )
    return HttpResponse(dumps(result, True))
Ejemplo n.º 6
0
def get_snap_comments(request, snap_id=None):
    limit, offset = get_paginate_info(request.GET)

    session = get_session()

    snap = session.query(Snap).get(snap_id)
    if not snap :
        result = dict(success=False, message=u'snaps.views.get_snap_comments: no snap with snap id {snap_id}'.format(snap_id=snap_id))
        return HttpResponse(dumps(result))

    comments = session.query(SnapComment).filter_by(snap_id=snap_id).limit(limit).offset(offset).all()
    
    data = dict(
        comment_list = to_dict(comments),
        )

    session.close()
    result = dict(success=True, message=u'snaps.views.get_snap_comments: comment of Snap {snap_id} from {start} to {end}'.format(snap_id=snap_id, start=offset, end=offset+limit), data=data)
    return HttpResponse(dumps(result))