Commits

Odd Simon Simonsen committed e3d1269 Merge

Merged.

Comments (0)

Files changed (2)

new_group_format.diff

 # HG changeset patch
-# Parent b293006ed3e01873d1c70574c655bb1014b2bda6
+# Parent b6671c2768564e26143ebece3ac97464346e7c9f
 
 diff --git a/trac/ticket/query.py b/trac/ticket/query.py
 --- a/trac/ticket/query.py
 +++ b/trac/ticket/query.py
-@@ -48,6 +48,29 @@ from trac.web.chrome import (INavigation
- from trac.wiki.api import IWikiSyntaxProvider
+@@ -49,6 +49,29 @@ from trac.wiki.api import IWikiSyntaxPro
  from trac.wiki.macros import WikiMacroBase # TODO: should be moved in .api
  
-+    
+ 
 +def field_to_string(d):
 +    try:
 +        s = ''
 +    except (IndexError, TypeError), e:
 +        pass
 +    return None
- 
++
  class QuerySyntaxError(TracError):
      """Exception raised when a ticket query cannot be parsed from a string."""
+ 
 @@ -65,7 +88,7 @@ class Query(object):
      clause_re = re.compile(r'(?P<clause>\d+)_(?P<field>.+)$')
  
          self.format = format
          self.default_page = 1
          self.items_per_page = QueryModule(self.env).items_per_page
-@@ -135,14 +156,22 @@ class Query(object):
+@@ -135,14 +156,21 @@ class Query(object):
          if self.order != 'id' and self.order not in field_names:
              (self.order, self.desc) = ('priority', 0)
  
 +                # 0.12 compatibility
 +                self.group['desc'] = True if groupdesc else False
 +
-+            if not self.group or self.group.get('field') not in field_names:
++            if not self.group or self.group['field'] not in field_names:
 +                default_group = QueryModule(self.env).default_group
 +                if default_group:
 +                    self.group = field_from_string(default_group)
 +                
-+                if not self.group \
-+                            or self.group.get('field') not in field_names:
++                if not self.group or self.group['field'] not in field_names:
 +                    self.group = None
  
          constraint_cols = {}
          for clause in self.constraints:
-@@ -282,8 +311,8 @@ class Query(object):
+@@ -282,8 +310,8 @@ class Query(object):
              cols.append(self.order)
  
          # Make sure to not show the column we group on.
 -        if self.group and self.group in cols:
 -            cols.remove(self.group)
-+        if self.group and self.group.get('field') in cols:
-+            cols.remove(self.group.get('field'))
++        if self.group and self.group['field'] in cols:
++            cols.remove(self.group['field'])
  
          return cols
  
-@@ -420,11 +449,15 @@ class Query(object):
+@@ -420,11 +448,15 @@ class Query(object):
              constraints.append(("or", empty))
          del constraints[-1:]
          
                            col=cols,
                            row=self.rows,
                            max=max,
-@@ -450,6 +483,7 @@ class Query(object):
+@@ -450,6 +482,7 @@ class Query(object):
              locale = req.locale
          self.get_columns()
          db = self.env.get_read_db()
-+        group_field = self.group.get('field') if self.group else None
++        group_field = self.group['field'] if self.group else None
  
          enum_columns = ('resolution', 'priority', 'severity')
          # Build the list of actual columns to query
-@@ -458,8 +492,8 @@ class Query(object):
+@@ -458,8 +491,8 @@ class Query(object):
              for col in args:
                  if not col in cols:
                      cols.append(col)
          if self.rows:
              add_cols('reporter', *self.rows)
          add_cols('status', 'priority', 'time', 'changetime', self.order)
-@@ -483,14 +517,14 @@ class Query(object):
+@@ -483,14 +516,14 @@ class Query(object):
  
          # Join with the enum table for proper sorting
          for col in [c for c in enum_columns
              sql.append("\n  LEFT OUTER JOIN %s ON (%s.name=%s)"
                         % (col, col, col))
  
-@@ -642,8 +676,8 @@ class Query(object):
+@@ -642,8 +675,8 @@ class Query(object):
              
          sql.append("\nORDER BY ")
          order_cols = [(self.order, self.desc)]
 -        if self.group and self.group != self.order:
 -            order_cols.insert(0, (self.group, self.groupdesc))
-+        if self.group and self.group.get('field') != self.order:
-+            order_cols.insert(0, (self.group.get('field'), self.group.get('desc')))
++        if self.group and self.group['field'] != self.order:
++            order_cols.insert(0, (self.group['field'], self.group['desc']))
  
          for name, desc in order_cols:
              if name in enum_columns:
-@@ -673,7 +707,7 @@ class Query(object):
+@@ -673,7 +706,7 @@ class Query(object):
                             % (desc, desc, col, desc))
              else:
                  sql.append("%s%s" % (col, desc))
                  sql.append(",")
          if self.order != 'id':
              sql.append(",t.id")  
-@@ -771,7 +805,7 @@ class Query(object):
+@@ -771,7 +804,7 @@ class Query(object):
                  elif ticket['changetime'] > orig_time:
                      ticket['changed'] = True
              if self.group:
 -                group_key = ticket[self.group]
-+                group_key = ticket[self.group.get('field')]
++                group_key = ticket[self.group['field']]
                  groups.setdefault(group_key, []).append(ticket)
                  if not groupsequence or group_key not in groupsequence:
                      groupsequence.append(group_key)
-@@ -930,12 +964,12 @@ class QueryModule(Component):
+@@ -930,12 +963,12 @@ class QueryModule(Component):
                  constraints = self._get_constraints(arg_list=arg_list)
              else:
                  query = Query.from_string(self.env, qstring)
                  constraints = query.constraints
  
              # Substitute $USER, or ensure no field constraints that depend
-@@ -949,6 +983,11 @@ class QueryModule(Component):
+@@ -949,6 +982,11 @@ class QueryModule(Component):
                              del clause[field]
                              break
  
          cols = args.get('col')
          if isinstance(cols, basestring):
              cols = [cols]
-@@ -963,13 +1002,12 @@ class QueryModule(Component):
+@@ -963,13 +1001,12 @@ class QueryModule(Component):
          max = args.get('max')
          if max is None and format in ('csv', 'tab'):
              max = 0 # unlimited unless specified explicitly
  
          if 'update' in req.args:
              # Reset session vars
-@@ -1423,18 +1461,18 @@ class TicketQueryMacro(WikiMacroBase):
+@@ -1423,18 +1460,18 @@ class TicketQueryMacro(WikiMacroBase):
  
          def ticket_groups():
              groups = []
                  q.order = order
                  href = q.get_href(formatter.context)
                  groups.append((v, [t for t in g], href, title))
-@@ -1456,7 +1494,7 @@ class TicketQueryMacro(WikiMacroBase):
+@@ -1456,7 +1493,7 @@ class TicketQueryMacro(WikiMacroBase):
                      [(tag.p(tag_('%(groupvalue)s %(groupname)s tickets:',
                                   groupvalue=tag.a(v, href=href, class_='query',
                                                    title=title),

new_order_format.diff

 # HG changeset patch
-# Parent b587d2c48654d657e5ad73d8ba21773ecec3b470
+# Parent f9526778aa521e1cd6528729128c1988bce9a182
 
 diff --git a/trac/ticket/query.py b/trac/ticket/query.py
 --- a/trac/ticket/query.py
  
          if group == '':
              self.group = group
-@@ -307,8 +320,8 @@ class Query(object):
+@@ -306,8 +319,8 @@ class Query(object):
              cols = cols[:7]
  
          # Make sure the column we order by is visible.
 +            cols.append(self.order['field'])
  
          # Make sure to not show the column we group on.
-         if self.group and self.group.get('field') in cols:
-@@ -422,14 +435,14 @@ class Query(object):
+         if self.group and self.group['field'] in cols:
+@@ -421,14 +434,14 @@ class Query(object):
  
          if id is None:
              id = self.id
  
          cols = self.get_columns()
          # don't specify the columns in the href if they correspond to
-@@ -456,7 +469,7 @@ class Query(object):
+@@ -455,7 +468,7 @@ class Query(object):
          
          return href.query(constraints,
                            report=id,
                            group=group,
                            col=cols,
                            row=self.rows,
-@@ -496,7 +509,7 @@ class Query(object):
+@@ -495,7 +508,7 @@ class Query(object):
              add_cols(group_field)
          if self.rows:
              add_cols('reporter', *self.rows)
          cols.extend([c for c in self.constraint_cols if not c in cols])
  
          custom_fields = [f['name'] for f in self.fields if f.get('custom')]
-@@ -517,14 +530,14 @@ class Query(object):
+@@ -516,14 +529,14 @@ class Query(object):
  
          # Join with the enum table for proper sorting
          for col in [c for c in enum_columns
              sql.append("\n  LEFT OUTER JOIN %s ON (%s.name=%s)"
                         % (col, col, col))
  
-@@ -675,8 +688,8 @@ class Query(object):
+@@ -674,8 +687,8 @@ class Query(object):
                             (','.join([str(id) for id in cached_ids])))
              
          sql.append("\nORDER BY ")
 -        order_cols = [(self.order, self.desc)]
--        if self.group and self.group.get('field') != self.order:
+-        if self.group and self.group['field'] != self.order:
 +        order_cols = [(self.order['field'], self.order['desc'])]
-+        if self.group and self.group.get('field') != self.order['field']:
-             order_cols.insert(0, (self.group.get('field'), self.group.get('desc')))
++        if self.group and self.group['field'] != self.order['field']:
+             order_cols.insert(0, (self.group['field'], self.group['desc']))
  
          for name, desc in order_cols:
-@@ -707,9 +720,9 @@ class Query(object):
+@@ -706,9 +719,9 @@ class Query(object):
                             % (desc, desc, col, desc))
              else:
                  sql.append("%s%s" % (col, desc))
              sql.append(",t.id")  
  
          if errors:
-@@ -768,11 +781,16 @@ class Query(object):
+@@ -767,11 +780,16 @@ class Query(object):
          wikify = set(f['name'] for f in self.fields 
                       if f['type'] == 'text' and f.get('format') == 'wiki')
  
          } for col in cols]
  
          fields = {'id': {'type': 'id', 'label': _("Ticket")}}
-@@ -964,12 +982,10 @@ class QueryModule(Component):
+@@ -963,12 +981,10 @@ class QueryModule(Component):
                  constraints = self._get_constraints(arg_list=arg_list)
              else:
                  query = Query.from_string(self.env, qstring)
                  constraints = query.constraints
  
              # Substitute $USER, or ensure no field constraints that depend
-@@ -983,6 +999,11 @@ class QueryModule(Component):
+@@ -982,6 +998,11 @@ class QueryModule(Component):
                              del clause[field]
                              break
  
          group = field_from_string(args.get('group'))
          if group and 'groupdesc' in args:
              group['desc'] = True if args.get('groupdesc') else False
-@@ -1004,7 +1025,7 @@ class QueryModule(Component):
+@@ -1003,7 +1024,7 @@ class QueryModule(Component):
              max = 0 # unlimited unless specified explicitly
          query = Query(self.env, report=req.args.get('report'),
                        constraints=constraints, cols=cols,