1. Alex Willmer
  2. trac-ticketlinks

Commits

Alex Willmer  committed dcb4868

Replace abandoned TicketLinksField with code using TicketSystem.parse_links()

  • Participants
  • Parent commits 1ebd151
  • Branches ticket-links-trunk

Comments (0)

Files changed (4)

File trac/ticket/api.py

View file
  • Ignore whitespace
             return label
 			
     def parse_links(self, value):
-        # TODO: Remove final invocation and exorcise this method
        if not value:
            return []
        return [int(id) for id in self.NUMBERS_RE.findall(value)]

File trac/ticket/links.py

View file
  • Ignore whitespace
         path.append(ticket.id)
 
         ticket_system = TicketSystem(self.env)
-        links = ticket[field]
+        links = ticket_system.parse_links(ticket[field])
         for link in links:
             linked_ticket= Ticket(self.env, link)
             cycle = self.find_cycle(linked_ticket, field, copy(path))

File trac/ticket/model.py

View file
  • Ignore whitespace
                 SELECT destination FROM ticket_links
                 WHERE source=%s and type=%s
             """, (tkt_id, end))
-            link_list = [destination for (destination,) in cursor]
+            link_list = []
+            for destination in cursor:
+                link_list.append(destination)
+
             link_list.sort()
-            self.values[end] = TicketLinksField(link_list)
+            self.values[end] = ', '.join(['#%s' % v for v in link_list])
             
 
     def __getitem__(self, name):
 				
             # Insert links
             for end in link_fields:
-                dst_ids =  self[end]
+                ticket_system = TicketSystem(self.env)
+                dst_ids =  ticket_system.parse_links(self[end])
                 # TODO: check if target exists!
                 if len(dst_ids) > 0:
                     cursor.executemany("""
 
             # Update links
             for end in (e for e in link_fields if e in self._old):
-                new_ids = set(self[end])
-                old_ids = set(self._old[end])
+                new_ids = set(api.parse_links(self[end]))
+                old_ids = set(api.parse_links(self._old[end]))
                 # New links added
                 for id in new_ids - old_ids:
                     cursor.execute("""
         return sorted(milestones, key=milestone_order)
 
 
-class TicketLinksField(list):
-    def __unicode__(self):
-        return u', '.join('#%i' % tkt for tkt in self)
-    
-    def render(self):
-        return unicode(self)
-
 def group_milestones(milestones, include_completed):
     """Group milestones into "open with due date", "open with no due date",
     and possibly "completed". Return a list of (label, milestones) tuples."""

File trac/ticket/web_ui.py

View file
  • Ignore whitespace
 
     def _prepare_data(self, req, ticket, absurls=False):
         return {'ticket': ticket,
-                'linked_tickets': [Ticket(self.env, tkt_id) 
-                                   for tkt_id in ticket['dependson']],
+                'linked_tickets': 
+                        [Ticket(self.env, tkt_id) 
+                         for tkt_id in TicketSystem(self.env)
+                                            .parse_links(ticket['dependson'])],
                 'context': Context.from_request(req, ticket.resource,
                                                 absurls=absurls),
                 'preserve_newlines': self.must_preserve_newlines}
                 if value in ('1', '0'):
                     field['rendered'] = self._query_link(req, name, value,
                                 value == '1' and _("yes") or _("no"))
-            elif type_ == 'text':
+            elif type_ in ('text', 'link'):
                 if field.get('format') == 'wiki':
                     field['rendered'] = format_to_oneliner(self.env, context,
                                                            ticket[name])
-            elif type_ == 'link':
-                if field.get('format') == 'wiki':
-                    field['rendered'] = \
-                                format_to_oneliner(self.env, context,
-                                                   unicode(ticket[name]))
             elif type_ == 'textarea':
                 if field.get('format') == 'wiki':
                     field['rendered'] = \