コード例 #1
0
ファイル: routes.py プロジェクト: gitter-badger/open-ods
def get_organisations():

    """

    Returns a list of ODS organisations

    Params:
    - offset=x (Offset start of results [0])
    - limit=y (Limit number of results [1000])
    - recordclass=HSCOrg/HSCSite/both (filter results by recordclass [both])
    - primaryRoleCode=xxxx (filter results to only those with a specific primaryRole)
    """

    log.debug(str.format("Cache Key: {0}", ocache.generate_cache_key()))
    offset = request.args.get('offset') if request.args.get('offset') else 0
    limit = request.args.get('limit') if request.args.get('limit') else 1000
    record_class = request.args.get('recordclass') if request.args.get('recordclass') else 'both'
    primary_role_code = request.args.get('primaryRoleCode' if request.args.get('primaryRoleCode') else None)
    log.debug(offset)
    log.debug(limit)
    log.debug(record_class)
    log.debug(primary_role_code)
    data = db.get_org_list(offset, limit, record_class, primary_role_code)

    if data:
        result = {'organisations': data}
        return jsonify(result)
    else:
        return Response("404: Not Found", status.HTTP_404_NOT_FOUND )
コード例 #2
0
ファイル: routes.py プロジェクト: gitter-badger/open-ods
def search_organisations(search_text):

    """

    Returns a list of organisations

    Params:
    - offset=x (Offset start of results by x)
    - limit=y (Retrieve y results)
    """

    log.debug(str.format("Cache Key: {0}", ocache.generate_cache_key()))
    offset = request.args.get('offset') if request.args.get('offset') else 0
    limit = request.args.get('limit') if request.args.get('limit') else 1000
    log.debug(offset)
    log.debug(limit)
    orgs = db.search_organisation(search_text)

    if orgs:
        result = {'organisations': orgs}
        return jsonify(result)

    else:
        return "Not found", status.HTTP_404_NOT_FOUND