예제 #1
0
파일: api.py 프로젝트: Lunga001/bika.lims-1
def get_batched(context, portal_type=None, uid=None, endpoint=None, **kw):
    """Get batched results
    """
    # TODO: to move to baobab lims jsonapi -----
    pm = getToolByName(context, 'portal_membership')
    roles = pm.getAuthenticatedMember().getRoles()
    if 'EMS' in roles or uid == "allowSharing":
        uid = None
        if portal_type == 'Sample':
            kw['object_provides'] = ISharableSample.__identifier__
            req.get_request().form["catalog"] = "portal_catalog"
        else:
            raise Unauthorized(
                "You don't have access permission to {}".format(portal_type))

    # TODO: ------
    # fetch the catalog results
    results = get_search_results(portal_type=portal_type, uid=uid, **kw)

    # fetch the batch params from the request
    size = req.get_batch_size()
    start = req.get_batch_start()

    # check for existing complete flag
    complete = req.get_complete(default=_marker)
    if complete is _marker:
        # if the uid is given, get the complete information set
        complete = uid and True or False

    # return a batched record
    return get_batch(results,
                     size,
                     start,
                     endpoint=endpoint,
                     complete=complete)
예제 #2
0
def get_batched(context, portal_type=None, uid=None, endpoint=None, **kw):
    """Get batched results
    """
    # TODO: to move to baobab lims jsonapi -----
    pm = getToolByName(context, 'portal_membership')
    roles = pm.getAuthenticatedMember().getRoles()
    if 'EMS' in roles or uid == "allowSharing":
        uid = None
        if portal_type == 'Sample':
            kw['object_provides'] = ISharableSample.__identifier__
            req.get_request().form["catalog"] = "portal_catalog"
        else:
            raise Unauthorized("You don't have access permission to {}".format(portal_type))

    # TODO: ------
    # fetch the catalog results
    results = get_search_results(portal_type=portal_type, uid=uid, **kw)

    # fetch the batch params from the request
    size = req.get_batch_size()
    start = req.get_batch_start()

    # check for existing complete flag
    complete = req.get_complete(default=_marker)
    if complete is _marker:
        # if the uid is given, get the complete information set
        complete = uid and True or False

    # return a batched record
    return get_batch(results, size, start, endpoint=endpoint,
                     complete=complete)
예제 #3
0
파일: api.py 프로젝트: Lunga001/bika.lims-1
def get_record(uid=None):
    """Get a single record
    """
    obj = None
    if uid is not None:
        obj = get_object_by_uid(uid)
    else:
        obj = get_object_by_request()
    if obj is None:
        fail(404, "No object found")
    complete = req.get_complete(default=_marker)
    if complete is _marker:
        complete = True
    items = make_items_for([obj], complete=complete)
    return u.first(items)
예제 #4
0
def get_record(uid=None):
    """Get a single record
    """
    obj = None
    if uid is not None:
        obj = get_object_by_uid(uid)
    else:
        obj = get_object_by_request()
    if obj is None:
        fail(404, "No object found")
    complete = req.get_complete(default=_marker)
    if complete is _marker:
        complete = True
    items = make_items_for([obj], complete=complete)
    return u.first(items)
예제 #5
0
def get_batched(portal_type=None, uid=None, endpoint=None, **kw):
    """Get batched results
    """

    # fetch the catalog results
    results = get_search_results(portal_type=portal_type, uid=uid, **kw)

    # fetch the batch params from the request
    size = req.get_batch_size()
    start = req.get_batch_start()

    # check for existing complete flag
    complete = req.get_complete(default=_marker)
    if complete is _marker:
        # if the uid is given, get the complete information set
        complete = uid and True or False

    # return a batched record
    return get_batch(results, size, start, endpoint=endpoint,
                     complete=complete)
예제 #6
0
def get_batched(portal_type=None, uid=None, endpoint=None, **kw):
    """Get batched results
    """

    # fetch the catalog results
    results = get_search_results(portal_type=portal_type, uid=uid, **kw)

    # fetch the batch params from the request
    size = req.get_batch_size()
    start = req.get_batch_start()

    # check for existing complete flag
    complete = req.get_complete(default=_marker)
    if complete is _marker:
        # if the uid is given, get the complete information set
        complete = uid and True or False

    # return a batched record
    return get_batch(results,
                     size,
                     start,
                     endpoint=endpoint,
                     complete=complete)