Commits

Tetsuya Morimoto committed b38a612

fixed to show the relationships field with textarea in query

Comments (0)

Files changed (1)

ticketref/web_ui.py

 
     def _filter_groups(self, req, data):
         fields_tref = data["fields"].get(TREF)
+        fields_tref_type = ""
         if fields_tref:  # column checkbox/select option
             fields_tref["label"] = _("Relationships")
+            fields_tref_type = fields_tref["type"]
         for header in data["headers"]:  # list view header
             if header["name"] == TREF:
                 header["label"] = _("Relationships")
         for group, tickets in data["groups"]:
             for ticket in tickets:
                 if TREF in ticket:
-                    ticket[TREF] = self._link_refs(req, ticket[TREF])
+                    if fields_tref_type == u"textarea":
+                        ticket[TREF] = self._link_textarea(req, ticket[TREF])
+                    elif fields_tref_type == u"text":
+                        ticket[TREF] = self._link_refs(req, ticket[TREF])
 
     def _filter_row_groups(self, req, data):
         for headers in data["header_groups"]:
                 items_tag.append(tag.span(verbose_items[:-1], **vattr))
         return tag(items_tag)
 
+    def _link_textarea(self, req, refs_text):
+        items = []
+        for ref_id in sorted(cnv_text2list(refs_text)):
+            elem = u"#%s" % ref_id
+            try:
+                ticket = Ticket(self.env, ref_id)
+                if "TICKET_VIEW" in req.perm(ticket.resource):
+                    title = shorten_line(ticket["summary"])
+                    elem = u"#%s %s" % (ref_id, title)
+            except ResourceNotFound:
+                pass  # not supposed to happen, just in case
+            items.extend([elem, u", "])
+        return u"".join(item for item in items[:-1])
+
     def _link_new(self, req, ticket, field):
         param = {TREF: ticket.id}
         for field in COPY_TICKET_FIELDS: