allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject allura git commit: [#8069] always have an "assigned_to" key in Ticket.index() since an arbitrary ticket is selected in paged_query_or_search and its keys used for solr param translation. Similar for other artifacts
Date Wed, 23 Mar 2016 16:35:01 GMT
Repository: allura
Updated Branches:
  refs/heads/db/8069 [created] ad2a566a7


[#8069] always have an "assigned_to" key in Ticket.index() since an arbitrary ticket is selected
in paged_query_or_search and its keys used for solr param translation.  Similar for other
artifacts


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

Branch: refs/heads/db/8069
Commit: ad2a566a773c8062d0d2d82e305d110dc5536fdd
Parents: bc167b9
Author: Dave Brondsema <dave@brondsema.net>
Authored: Wed Mar 23 12:34:55 2016 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Wed Mar 23 12:34:55 2016 -0400

----------------------------------------------------------------------
 Allura/allura/model/artifact.py                         | 12 +++++-------
 Allura/allura/model/project.py                          |  7 +++----
 ForgeTracker/forgetracker/model/ticket.py               |  7 +++----
 .../forgetracker/tests/unit/test_ticket_model.py        |  7 +++++++
 4 files changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ad2a566a/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index ed5d424..0a3cb02 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -478,8 +478,9 @@ class Snapshot(Artifact):
         if original:
             original_index = original.index()
             result.update(original_index)
-            result['title'] = '%s (version %d)' % (
-                h.get_first(original_index, 'title'), self.version)
+            result['title'] = '%s (version %d)' % (h.get_first(original_index, 'title'),
self.version)
+        else:
+            result['title'] = None
         result.update(
             id=self.index_id(),
             version_i=self.version,
@@ -691,8 +692,7 @@ class Award(Artifact):
             short_s=self.short,
             timestamp_dt=self.timestamp,
             full_s=self.full)
-        if self.created_by:
-            result['created_by_s'] = self.created_by.name
+        result['created_by_s'] = self.created_by.name if self.created_by else None
         return result
 
     @property
@@ -739,8 +739,7 @@ class AwardGrant(Artifact):
             short_s=self.short,
             timestamp_dt=self.timestamp,
             full_s=self.full)
-        if self.award:
-            result['award_s'] = self.award.short
+        result['award_s'] = self.award.short if self.award else None
         return result
 
     @property
@@ -763,7 +762,6 @@ class AwardGrant(Artifact):
             return None
 
 
-
 class RssFeed(FG.Rss201rev2Feed):
     def rss_attributes(self):
         attrs = super(RssFeed, self).rss_attributes()

http://git-wip-us.apache.org/repos/asf/allura/blob/ad2a566a/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index e26e405..963145e 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -1131,10 +1131,9 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
                       short_description_t=self.short_description,
                       labels_t=' '.join(self.labels),
                       summary_t=self.summary,
-                    )
-        if self.category:
-            fields.update(category_name_t=self.category.name,
-                          category_description_t=self.category.description)
+                      category_name_t=self.category.name if self.category else None,
+                      category_description_t=self.category.description if self.category else
None,
+                      )
         return dict(provider.index_project(self), **fields)
 
     def should_update_index(self, old_doc, new_doc):

http://git-wip-us.apache.org/repos/asf/allura/blob/ad2a566a/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index b355262..b417604 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -705,10 +705,9 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                 result[k + solr_type] = (v or
                                          get_default_for_solr_type(solr_type))
 
-        if self.reported_by:
-            result['reported_by_s'] = self.reported_by.username
-        if self.assigned_to:
-            result['assigned_to_s'] = self.assigned_to.username
+        result['reported_by_s'] = self.reported_by.username if self.reported_by else None
+        result['assigned_to_s'] = self.assigned_to.username if self.assigned_to else None
+
         # Tracker uses search with default solr parser. It would match only on
         # `text`, so we're appending all other field values into `text`, to
         # match on it too.

http://git-wip-us.apache.org/repos/asf/allura/blob/ad2a566a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
index 889f342..3b6f318 100644
--- a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
@@ -357,3 +357,10 @@ class TestTicketModel(TrackerTestWithModel):
         search.assert_called_once_with(app_cfg, user, solr_query, filter=filter, sort=None,
limit=None, page=0, **kw)
         assert_equal(query.call_count, 0)
         assert_equal(tsearch.query_filter_choices.call_count, 0)
+
+    def test_index(self):
+        idx = Ticket(ticket_num=2, summary="ticket2", labels=["mylabel", "other"]).index()
+        assert_equal(idx['summary_t'], 'ticket2')
+        assert_equal(idx['labels_t'], 'mylabel other')
+        assert_equal(idx['reported_by_s'], 'test-user')
+        assert_equal(idx['assigned_to_s'], None)  # must exist at least


Mime
View raw message