Example #1
0
    def get(request, user_id=None):

        # Single user
        if user_id:
            u = get_object(LocastUser, id=user_id)
            content = api_serialize(u)
            return APIResponseOK(content=content, total=1)
        
        # Multiple users
        else:
            q = QueryTranslator(LocastUser, ruleset)
            query = request.GET.copy()

            objs = total = pg = None
            try:
                objs = q.filter(query)
                objs, total, pg = paginate(objs, request.GET)
            except InvalidParameterException, e:
                raise APIBadRequest(e.message)

            user_arr = []
            for m in objs:
                user_arr.append(api_serialize(m, request))

            return APIResponseOK(content=user_arr, total=total, pg=pg)
Example #2
0
    def get(request, coll_id=None):

        if coll_id:
            collection = get_object(Collection, id=coll_id)
            collection_dict = api_serialize(collection, request)

            return APIResponseOK(content=collection_dict, total=1)

        else:
            query = request.GET.copy()
            q = QueryTranslator(Collection, ruleset)
            try:
                objs = q.filter(query)
            except InvalidParameterException, e:
                raise APIBadRequest(e)

            objs, total, pg = paginate(objs, query)

            collection_arr = []
            for i in objs:
                collection_arr.append(api_serialize(i, request))

            return APIResponseOK(content=collection_arr, total=total, pg=pg)
Example #3
0
    def get(request, coll_id = None):

        if coll_id:
            collection = get_object(Collection, id=coll_id)
            collection_dict = api_serialize(collection, request)
            
            return APIResponseOK(content=collection_dict, total=1)

        else:
            query = request.GET.copy()
            q = QueryTranslator(Collection, ruleset)
            try:
                objs = q.filter(query)
            except InvalidParameterException, e:
                raise APIBadRequest(e)

            objs, total, pg = paginate(objs, query)

            collection_arr = []
            for i in objs:
                collection_arr.append(api_serialize(i, request))

            return APIResponseOK(content=collection_arr, total=total, pg=pg)