def testFindAncestorComponents_NoMatch(self):
   config = tracker_bizobj.MakeDefaultProjectIssueConfig(789)
   cd = tracker_pb2.ComponentDef(component_id=1, path='UI>Splash')
   config.component_defs.append(tracker_pb2.ComponentDef(
       component_id=2, path='UI>AboutBox'))
   actual = tracker_bizobj.FindAncestorComponents(config, cd)
   self.assertEqual([], actual)
Beispiel #2
0
def GetCcIDsForComponentAndAncestors(config, cd):
    """Return auto-cc'd user IDs for the given component and ancestors."""
    result = set(cd.cc_ids)
    ancestors = tracker_bizobj.FindAncestorComponents(config, cd)
    for anc_cd in ancestors:
        result.update(anc_cd.cc_ids)

    return result
Beispiel #3
0
def CanEditComponentDef(effective_ids, perms, project, component_def, config):
  """Return True if a user can edit the given component definition."""
  if not effective_ids.isdisjoint(component_def.admin_ids):
    return True  # Component admins can edit that component.

  # Check to see if user is admin of any parent component.
  parent_components = tracker_bizobj.FindAncestorComponents(
      config, component_def)
  for parent in parent_components:
    if not effective_ids.isdisjoint(parent.admin_ids):
      return True

  return perms.CanUsePerm(EDIT_PROJECT, effective_ids, project, [])
 def testFindAncestorComponents_Empty(self):
   config = tracker_bizobj.MakeDefaultProjectIssueConfig(789)
   cd = tracker_pb2.ComponentDef(component_id=1, path='UI>Splash')
   actual = tracker_bizobj.FindAncestorComponents(config, cd)
   self.assertEqual([], actual)