Commits

Alex Willmer  committed fb2b880

Skeleton of blocking behaviour

  • Participants
  • Parent commits 6db189c
  • Branches ticket-links-trunk

Comments (0)

Files changed (2)

File trac/ticket/api.py

     def render_end(end):
         """returns label"""
 
+    def is_blocker(end):
+        """Return True if tickets linked by end block closing.
+        """
+
 class IMilestoneChangeListener(Interface):
     """Extension point interface for components that require notification
     when milestones are created, modified, or deleted."""

File trac/ticket/links.py

     PARENT_END = 'parent'
     
     def __init__(self):
-        self._links, self._labels, self._validators = self._get_links_config()
+        self._links, self._labels, \
+        self._validators, self._blockers = self._get_links_config()
 
     def get_ends(self):
         return self._links
     
     def render_end(self, end):
         return self._labels[end]
-        
+    
+    def is_blocker(self, end):
+        return self.blockers[end]
+    
     def prepare_ticket(self, req, ticket, fields, actions):
         pass
         
         links = []
         labels = {}
         validators = {}
+        blockers = {}
         config = self.config['ticket-links']
         for name in [option for option, _ in config.options()
                      if '.' not in option]:
             if len(ends) > 1:
                 end2 = ends[1]
             links.append((end1, end2))
+            
             label1 = config.get(end1 + '.label') or end1.capitalize()
             labels[end1] = label1
             if end2:
                 label2 = config.get(end2 + '.label') or end2.capitalize()
                 labels[end2] = label2
+            
             validator = config.get(name + '.validator')
             if validator == 'no_cycle':
                 validators[end1] = self.validate_no_cycle
                     validators[end1] = self.validate_parent
                 elif end2 == self.PARENT_END:
                     validators[end2] = self.validate_parent
-
-        return links, labels, validators
+            
+            blockers[end1] = config.getbool(end1 + '.blocks', default=False)
+            if end2:
+                blockers[end2] = config.getbool(end2 + '.blocks', default=False)
+            
+        return links, labels, validators, blockers
 
 
     def find_cycle(self, ticket, field, path):