Ejemplo n.º 1
0
def oparl_body_organization_data(params):
  search_params = oparl_generate_list_search_params(params)
  data = db.get_organization(search_params = search_params, limit=app.config['oparl_items_per_page'])
  data = oparl_generate_list_items(params=params,
                                   search_params=search_params,
                                   result_count=db.get_organization_count(search_params=search_params),
                                   data=data,
                                   type='organization')
  for key, single in enumerate(data['data']):
    data['data'][key] = oparl_organization_layout(data=single, params=params)
  return data
Ejemplo n.º 2
0
def oparl_organization_data(params):
  data = db.get_organization(search_params={'_id': ObjectId(params['_id'])})
  if len(data) == 1:
    data[0]['body'] = "%s/oparl/body/%s%s" % (app.config['api_url'], data[0]['body'].id, generate_postfix(params))
    data[0]['membership'] = generate_sublist_url(params=params, main_type='organization', sublist_type='membership')
    data[0]['meeting'] = generate_sublist_url(params=params, main_type='organization', sublist_type='meeting')
    data[0]['@type'] = 'OParlCommittee'
    data[0]['@id'] = data[0]['_id']
    return data[0]
  elif len(data) == 0:
    abort(404)
Ejemplo n.º 3
0
def oparl_body_organization_data(params):
  search_params = oparl_generate_list_search_params(params)
  data = db.get_organization(search_params = search_params, limit=app.config['oparl_items_per_page'])
  data = oparl_generate_list_items(params=params,
                                   search_params=search_params,
                                   result_count=db.get_organization_count(search_params=search_params),
                                   data=data,
                                   type='organization')
  for key, single in enumerate(data['items']):
    data['items'][key] = oparl_organization_layout(data=single, params=params)
  return data
Ejemplo n.º 4
0
async def organizations(request):
    organization_name = request.match_info.get('organization', None)

    if organization_name:
        # If organization name parameter is in the request, search whether it is in database
        organization = db.get_organization(request.app['session'],
                                           organization_name)

        if organization is None:
            # If not in database, request the API
            response = get_repos(organization_name)
            # And save it for later requests
            db.save_organization(request.app['session'], organization_name,
                                 response)
        else:
            # Organization is in database
            response = encoders.encode(organization)

    else:
        response = get_organizations()

    return web.json_response(response)
Ejemplo n.º 5
0
def oparl_organizations_data(params):
  return db.get_organization(organization_list=True,
                             add_prefix = "%s/oparl/organization/" % app.config['api_url'],
                             add_postfix=generate_postfix(params))
Ejemplo n.º 6
0
def oparl_body_organization_data(params):
  data = db.get_organization(organization_list = True,
                             search_params = {'body': DBRef('body', ObjectId(params['body_id']))},
                             add_prefix = "%s/oparl/organization/" % app.config['api_url'],
                             add_postfix = generate_postfix(params))
  return data
Ejemplo n.º 7
0
def oparl_organization_data(params):
  data = db.get_organization(search_params={'_id': ObjectId(params['_id'])})
  if len(data) == 1:
    return oparl_organization_layout(data[0], params)
  else:
    abort(404)
Ejemplo n.º 8
0
def oparl_organization_data(params):
  data = db.get_organization(search_params={'_id': ObjectId(params['_id'])})
  if len(data) == 1:
    return oparl_organization_layout(data[0], params)
  else:
    abort(404)