allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [32/38] git commit: [#4019] ticket:560 Added 'Not set' option to ticket's filters
Date Wed, 30 Apr 2014 18:16:04 GMT
[#4019] ticket:560 Added 'Not set' option to ticket's filters


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/32ec63ac
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/32ec63ac
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/32ec63ac

Branch: refs/heads/master
Commit: 32ec63ac315e759cbf422466031ef455d1473634
Parents: 61368d2
Author: Ferens Dmitriy <ferensdima@gmail.com>
Authored: Wed Mar 19 20:27:48 2014 +0200
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 30 15:55:14 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py                        | 10 +++++++++-
 ForgeTracker/forgetracker/widgets/ticket_search.py | 12 ++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/32ec63ac/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index b57859c..cd637ad 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -97,7 +97,15 @@ def search_artifact(atype, q, history=False, rows=10, short_timeout=False,
filte
         'mount_point_s:%s' % c.app.config.options.mount_point ]
     for name, values in (filter or {}).iteritems():
         field_name = name + '_s'
-        fq.append(' OR '.join('%s:%s' % (field_name, escape_solr_arg(v)) for v in values))
+        parts = []
+        for v in values:
+            # Specific solr syntax for empty fields
+            if v == '' or v is None:
+                part = '(-%s:[* TO *] AND *:*)' % (field_name,)
+            else:
+                part = '%s:%s' % (field_name, escape_solr_arg(v))
+            parts.append(part)
+        fq.append(' OR '.join(parts))
     if not history:
         fq.append('is_history_b:False')
     return search(q, fq=fq, rows=rows, short_timeout=short_timeout, ignore_errors=False,
**kw)

http://git-wip-us.apache.org/repos/asf/allura/blob/32ec63ac/ForgeTracker/forgetracker/widgets/ticket_search.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/widgets/ticket_search.py b/ForgeTracker/forgetracker/widgets/ticket_search.py
index 34078b4..d78f7d7 100644
--- a/ForgeTracker/forgetracker/widgets/ticket_search.py
+++ b/ForgeTracker/forgetracker/widgets/ticket_search.py
@@ -44,10 +44,14 @@ class TicketSearchResults(ew_core.SimpleForm):
 
     def __init__(self, filters, *args, **kw):
         super(TicketSearchResults, self).__init__(*args, **kw)
-        self.filters = {name: [{'value': val,
-                            'label': '%s (%s)' % (val, count),
-                            'selected': False} for val, count in field]
-                        for name, field in filters.iteritems()}
+        self.filters = {}
+        for name, field in filters.iteritems():
+            self.filters[name] = options = [{
+                'value': val,
+                'label': '%s (%s)' % (val, count),
+                'selected': False
+            } for val, count in field]
+            options.append({'value': '', 'label': 'Not set', 'selected': False})
 
     def resources(self):
         yield ew.JSLink('tracker_js/jquery.multiselect.min.js')


Mime
View raw message