Commits

Odd Simon Simonsen  committed 96be80a

Made `new_group_format` patch apply onto the other updated patches. Also some code standard changes (no more than 80 chars per line).

No functional changes, but there is now some mismatch on logic for `new_group_format` and one of the new tests do not pass.

  • Participants
  • Parent commits e9ee9e9

Comments (0)

Files changed (1)

File new_group_format.diff

 # HG changeset patch
-# Parent 681a3fa63d270d2007d45f380cb122695c262eda
+# Parent 2596727274ce6b710d5e329611545ac40293c357
 
-diff -r 681a3fa63d27 trac/ticket/query.py
---- a/trac/ticket/query.py	Sun Dec 18 21:44:21 2011 +0100
-+++ b/trac/ticket/query.py	Sun Dec 18 21:51:49 2011 +0100
+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.wiki.api import IWikiSyntaxProvider
  from trac.wiki.macros import WikiMacroBase # TODO: should be moved in .api
          self.format = format
          self.default_page = 1
          self.items_per_page = QueryModule(self.env).items_per_page
-@@ -142,18 +163,20 @@
-                 (self.order, self.desc) = ('priority', 0)
+@@ -135,14 +156,23 @@
+         if self.order != 'id' and self.order not in field_names:
+             (self.order, self.desc) = ('priority', 0)
  
-         # Handle empty string as a request to not group the result
--        if self.group != '' and self.group not in field_names:
--            default_group = QueryModule(self.env).default_group
--            if default_group:
--                if default_group[0] == '-':
--                    (self.group, self.groupdesc) = (default_group[1:], 1)
--                elif default_group[0] == '+':
--                    (self.group, self.groupdesc) = (default_group[1:], 0)
--                else:
--                    (self.group, self.groupdesc) = (default_group, 0)
--            
--            if self.group not in field_names:
--                (self.group, self.groupdesc) = (None, 0)
+-        self.group = self.group or QueryModule(self.env).default_group
+-        if self.group:
+-            if self.group[0] == '-':
+-                (self.group, self.groupdesc) = (self.group[1:], 1)
+-            elif self.group[0] == '+':
+-                (self.group, self.groupdesc) = (self.group[1:], 0)
+-        if self.group not in field_names:
+-            (self.group, self.groupdesc) = (None, 0)
 +        if group == '':
 +            self.group = group
 +        else:
 +            self.group = field_from_string(group)
-+            if self.group is not None and groupdesc is not None: # 0.12 compatibility
++            if self.group is not None and groupdesc is not None:
++                # 0.12 compatibility
 +                self.group['desc'] = True if groupdesc else False
 +
-+            if self.group is None or (self.group.get('field') != '' and self.group.get('field') not in field_names):
++            if self.group is None or (self.group.get('field') != '' \
++                            and self.group.get('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.get('field') not in field_names:
 +                    self.group = None
  
          constraint_cols = {}
          for clause in self.constraints:
-@@ -293,8 +316,8 @@
+@@ -282,8 +312,8 @@
              cols.append(self.order)
  
          # Make sure to not show the column we group on.
  
          return cols
  
-@@ -434,8 +457,7 @@
+@@ -423,8 +453,7 @@
          return href.query(constraints,
                            report=id,
                            order=order, desc=1 if desc else None,
                            col=cols,
                            row=self.rows,
                            max=max,
-@@ -461,6 +483,7 @@
+@@ -450,6 +479,7 @@
              locale = req.locale
          self.get_columns()
          db = self.env.get_read_db()
  
          enum_columns = ('resolution', 'priority', 'severity')
          # Build the list of actual columns to query
-@@ -469,8 +492,8 @@
+@@ -458,8 +488,8 @@
              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)
-@@ -494,14 +517,14 @@
+@@ -483,14 +513,14 @@
  
          # 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))
  
-@@ -653,8 +676,8 @@
+@@ -642,8 +672,8 @@
              
          sql.append("\nORDER BY ")
          order_cols = [(self.order, self.desc)]
  
          for name, desc in order_cols:
              if name in enum_columns:
-@@ -684,7 +707,7 @@
+@@ -673,7 +703,7 @@
                             % (desc, desc, col, desc))
              else:
                  sql.append("%s%s" % (col, desc))
                  sql.append(",")
          if self.order != 'id':
              sql.append(",t.id")  
-@@ -782,7 +805,7 @@
+@@ -771,7 +801,7 @@
                  elif ticket['changetime'] > orig_time:
                      ticket['changed'] = True
              if self.group:
                  groups.setdefault(group_key, []).append(ticket)
                  if not groupsequence or group_key not in groupsequence:
                      groupsequence.append(group_key)
-@@ -941,12 +964,12 @@
+@@ -930,12 +960,12 @@
                  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
-@@ -960,6 +983,12 @@
+@@ -949,6 +979,12 @@
                              del clause[field]
                              break
  
          cols = args.get('col')
          if isinstance(cols, basestring):
              cols = [cols]
-@@ -974,13 +1003,12 @@
+@@ -963,13 +999,12 @@
          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
-@@ -1434,18 +1462,18 @@
+@@ -1423,18 +1458,18 @@
  
          def ticket_groups():
              groups = []
                  q.order = order
                  href = q.get_href(formatter.context)
                  groups.append((v, [t for t in g], href, title))
-@@ -1467,7 +1495,7 @@
+@@ -1456,7 +1491,7 @@
                      [(tag.p(tag_('%(groupvalue)s %(groupname)s tickets:',
                                   groupvalue=tag.a(v, href=href, class_='query',
                                                    title=title),
                        tag.dl([(tag.dt(ticket_anchor(t)),
                                 tag.dd(t['summary'])) for t in g],
                               class_='wiki compact'))
-diff -r 681a3fa63d27 trac/ticket/templates/query.html
---- a/trac/ticket/templates/query.html	Sun Dec 18 21:44:21 2011 +0100
-+++ b/trac/ticket/templates/query.html	Sun Dec 18 21:51:49 2011 +0100
+diff --git a/trac/ticket/templates/query.html b/trac/ticket/templates/query.html
+--- a/trac/ticket/templates/query.html
++++ b/trac/ticket/templates/query.html
 @@ -184,12 +184,12 @@
              <option></option>
              <py:for each="field_name in field_names" py:with="field = fields[field_name]">
            <label for="groupdesc">descending</label>
          </p>
  
-diff -r 681a3fa63d27 trac/ticket/templates/query_results.html
---- a/trac/ticket/templates/query_results.html	Sun Dec 18 21:44:21 2011 +0100
-+++ b/trac/ticket/templates/query_results.html	Sun Dec 18 21:51:49 2011 +0100
+diff --git a/trac/ticket/templates/query_results.html b/trac/ticket/templates/query_results.html
+--- a/trac/ticket/templates/query_results.html
++++ b/trac/ticket/templates/query_results.html
 @@ -24,8 +24,8 @@
    <py:def function="group_heading(groupname, results)">
      <h2 class="report-result" py:if="groupname is not None"
                   count = ngettext('%(num)s match', '%(num)s matches', len(results))">
        ${grouplabel}: ${groupname} <span class="numrows">(${count})</span>
      </h2>
-diff -r 681a3fa63d27 trac/ticket/tests/query.py
---- a/trac/ticket/tests/query.py	Sun Dec 18 21:44:21 2011 +0100
-+++ b/trac/ticket/tests/query.py	Sun Dec 18 21:51:49 2011 +0100
+diff --git a/trac/ticket/tests/query.py b/trac/ticket/tests/query.py
+--- a/trac/ticket/tests/query.py
++++ b/trac/ticket/tests/query.py
 @@ -172,6 +172,17 @@
          self.assertEqual([], args)
          tickets = query.execute(self.req)
      def test_grouped_by_priority(self):
          query = Query(self.env, group='priority')
          sql, args = query.get_sql()
-diff -r 681a3fa63d27 trac/ticket/tests/wikisyntax.py
---- a/trac/ticket/tests/wikisyntax.py	Sun Dec 18 21:44:21 2011 +0100
-+++ b/trac/ticket/tests/wikisyntax.py	Sun Dec 18 21:51:49 2011 +0100
+diff --git a/trac/ticket/tests/wikisyntax.py b/trac/ticket/tests/wikisyntax.py
+--- a/trac/ticket/tests/wikisyntax.py
++++ b/trac/ticket/tests/wikisyntax.py
 @@ -235,7 +235,7 @@
  <a class="query" href="/query?group=owner&amp;order=priority">query:group=owner</a>
  </p>