allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject allura git commit: [#8059] Excluded options from deleted tickets in search's dropdown filter
Date Tue, 25 Apr 2017 14:40:30 GMT
Repository: allura
Updated Branches:
  refs/heads/master 9c605a6d1 -> ae3ec550a


[#8059] Excluded options from deleted tickets in search's dropdown filter


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

Branch: refs/heads/master
Commit: ae3ec550a0718740378f930c590e0b5cea52da65
Parents: 9c605a6
Author: huzaifafaruqui <huzaifafaruqui@outlook.com>
Authored: Wed Mar 15 23:48:25 2017 +0530
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Tue Apr 25 14:40:09 2017 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/model/ticket.py             | 14 +++++++++++++-
 .../forgetracker/tests/functional/test_root.py        |  2 +-
 ForgeTracker/forgetracker/tracker_main.py             | 12 +++++++++---
 3 files changed, 23 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ae3ec550/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index da4e158..44da697 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -1216,8 +1216,11 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                 # also query for choices for filter options right away
                 params = kw.copy()
                 params.update(tsearch.FACET_PARAMS)
+                q_ = q
+                if not show_deleted:
+                    q_ = cls.not_deleted_query(q_)
                 matches = search_artifact(
-                    cls, q, short_timeout=True,
+                    cls, q_, short_timeout=True,
                     rows=limit, sort=refined_sort, start=start, fl='ticket_num_i',
                     filter=filter, **params)
             else:
@@ -1255,6 +1258,13 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                     solr_error=solr_error, **kw)
 
     @classmethod
+    def not_deleted_query(cls, search_query):
+        """Update query to exclude deleted tickets
+        search_query - query in solr syntax
+        """
+        return search_query + ' && deleted:False'
+
+    @classmethod
     def paged_query_or_search(cls, app_config, user, query, search_query, filter,
                               limit=None, page=0, sort=None, **kw):
         """Switch between paged_query and paged_search based on filter.
@@ -1272,6 +1282,8 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
             result = cls.paged_query(app_config, user, query, sort=sort, limit=limit, page=page,
**kw)
             t = cls.query.find().first()
             if t:
+                if not kw.get('show_deleted',False):
+                    search_query = cls.not_deleted_query(search_query)
                 search_query = cls.translate_query(search_query, t.index())
             result['filter_choices'] = tsearch.query_filter_choices(search_query)
         else:

http://git-wip-us.apache.org/repos/asf/allura/blob/ae3ec550/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 77a563b..c3d0ac4 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -2406,7 +2406,7 @@ class TestFunctionalController(TrackerTestController):
         r = self.app.get('/bugs/')
         assert '<option value="open">open (2)</option>' in r
         assert query_filter_choices.call_count == 1
-        assert query_filter_choices.call_args[0][0] == '!status_s:wont-fix && !status_s:closed'
+        assert query_filter_choices.call_args[0][0] == '!status_s:wont-fix && !status_s:closed
&& deleted_b:False'
 
     def test_rate_limit_new(self):
         self.new_ticket(summary='First ticket')

http://git-wip-us.apache.org/repos/asf/allura/blob/ae3ec550/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 44053d9..5fa57ca 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -720,7 +720,9 @@ class RootController(BaseController, FeedController):
         show_deleted = [False]
         if deleted and has_access(c.app, 'delete'):
             show_deleted = [False, True]
-
+        elif deleted and not has_access(c.app, 'delete'):
+            deleted = False
+            
         # it's just our original query mangled and sent back to us
         kw.pop('q', None)
         result = TM.Ticket.paged_query_or_search(c.app.config, c.user,
@@ -823,7 +825,9 @@ class RootController(BaseController, FeedController):
     def search(self, q=None, query=None, project=None, columns=None, page=0, sort=None,
                deleted=False, filter=None, **kw):
         require(has_access(c.app, 'read'))
-
+   
+        if deleted and not has_access(c.app, 'delete'):
+            deleted = False
         if query and not q:
             q = query
         c.bin_form = W.bin_form
@@ -1937,7 +1941,9 @@ class MilestoneController(BaseController):
         show_deleted = [False]
         if deleted and has_access(c.app, 'delete'):
             show_deleted = [False, True]
-
+        elif deleted and not has_access(c.app, 'delete'):
+            deleted = False
+            
         result = TM.Ticket.paged_query_or_search(c.app.config, c.user,
                                                  self.mongo_query,
                                                  self.solr_query,


Mime
View raw message