Alex Willmer avatar Alex Willmer committed 1ebd151

Abandoned TicketLinksField approach, for posterity

Comments (0)

Files changed (6)

trac/htdocs/css/ticket.css

 #ticket table.properties td p:last-child { margin-bottom: 0 }
 #ticket table.properties .description { border-top: 1px solid #dd9 }
 
-#ticket .description h3 {
+#ticket .description h3,#ticket .linked h3 {
  border-bottom: 1px solid #dd9;
  color: #663;
  font-size: 100%;

trac/ticket/api.py

         
 class ITicketLinkController(Interface):
     
-    def get_links():
+    def get_ends():
         """returns iterable of '(end1, end2)' tuples that make up a link. 
         'end2' can be None for unidirectional links."""
 
             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)]

trac/ticket/links.py

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

trac/ticket/model.py

                 SELECT destination FROM ticket_links
                 WHERE source=%s and type=%s
             """, (tkt_id, end))
-            link_list = []
-            for destination in cursor:
-                link_list.append(destination)
-
+            link_list = [destination for (destination,) in cursor]
             link_list.sort()
-            self.values[end] = ', '.join(['#%s' % v for v in link_list])
+            self.values[end] = TicketLinksField(link_list)
             
 
     def __getitem__(self, name):
 				
             # Insert links
             for end in link_fields:
-                ticket_system = TicketSystem(self.env)
-                dst_ids =  ticket_system.parse_links(self[end])
+                dst_ids =  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(api.parse_links(self[end]))
-                old_ids = set(api.parse_links(self._old[end]))
+                new_ids = set(self[end])
+                old_ids = set(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."""

trac/ticket/templates/ticket_box.html

     </div>
     <br py:if="not ticket.description" style="clear: both" />
   </div>
+  <div class="linked">
+    <h3>Linked Issues (${len(linked_tickets)})</h3>
+    <table class="listing tickets">
+      <thead>
+        <tr style="white-space: nowrap;">
+          <th>Ticket</th>
+          <th>Component</th>
+          <th>Status</th>
+          <th style="width:100%;">Summary</th>
+          <th>Last modified</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr py:for="ticket in linked_tickets">
+          <td class="ticket">${ticket.id}</td>
+          <td class="component">${ticket.component}</td>
+          <td class="version">${ticket.status}</td>
+          <td class="summary">${ticket.summary}</td>
+          <td class="date">${dateinfo(ticket.changetime)}</td>
+        </tr>
+      </tbody>
+    </table>
+  </div>
 </div>

trac/ticket/web_ui.py

 
     def _prepare_data(self, req, ticket, absurls=False):
         return {'ticket': ticket,
+                'linked_tickets': [Ticket(self.env, tkt_id) 
+                                   for tkt_id in 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_ in ('text', 'link'):
+            elif type_ == 'text':
                 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'] = \
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.