Example #1
0
def has_project_access(project_id):
  metadata = projects.get_metadata(project_id)
  super_group = read_acl_cfg().project_access_group
  return (
      auth.is_admin() or
      super_group and auth.is_group_member(super_group) or
      metadata and config.api._has_access(metadata.access)
  )
Example #2
0
def get_projects():
  """Returns list of projects with metadata and repo info.

  Does not return projects that have no repo information. It might happen due
  to eventual consistency.

  Caches results in main memory for 10 min.
  """
  result = []
  for p in projects.get_projects():
    repo_type, repo_url = projects.get_repo(p.id)
    if repo_type is None:
      # Not yet consistent.
      continue
    metadata = projects.get_metadata(p.id)
    result.append(Project(
        id=p.id,
        name=metadata.name or None,
        repo_type=repo_type,
        repo_url=repo_url,
    ))
  return result
Example #3
0
def get_projects():
  """Returns list of projects with metadata and repo info.

  Does not return projects that have no repo information. It might happen due
  to eventual consistency.

  Caches results in main memory for 10 min.
  """
  result = []
  for p in projects.get_projects():
    repo_type, repo_url = projects.get_repo(p.id)
    if repo_type is None:
      # Not yet consistent.
      continue
    metadata = projects.get_metadata(p.id)
    result.append(Project(
        id=p.id,
        name=metadata.name or None,
        repo_type=repo_type,
        repo_url=repo_url,
    ))
  return result
Example #4
0
def has_project_access(project_id):
    metadata = projects.get_metadata(project_id)
    super_group = read_acl_cfg().project_access_group
    return (auth.is_admin()
            or super_group and auth.is_group_member(super_group)
            or metadata and config.api._has_access(metadata.access))