allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject allura git commit: Don't error out when reindexing a post/thread that has been deleted
Date Mon, 25 Jul 2016 15:46:02 GMT
Repository: allura
Updated Branches:
  refs/heads/master e5794323f -> 1bef5bebc


Don't error out when reindexing a post/thread that has been deleted


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

Branch: refs/heads/master
Commit: 1bef5bebc2b0c326142ddb1e811c3a9373513e4a
Parents: e579432
Author: Dave Brondsema <dave@brondsema.net>
Authored: Fri Jul 15 14:54:55 2016 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Mon Jul 25 11:45:17 2016 -0400

----------------------------------------------------------------------
 Allura/allura/model/discuss.py               | 12 +++++++-----
 Allura/allura/tests/model/test_discussion.py | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1bef5beb/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 25510c8..b3cf04b 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -600,11 +600,13 @@ class Post(Message, VersionedArtifact, ActivityObject):
 
     @property
     def subject(self):
-        subject = self.thread.subject
-        if not subject:
-            artifact = self.thread.artifact
-            if artifact:
-                subject = getattr(artifact, 'email_subject', '')
+        subject = None
+        if self.thread:
+            subject = self.thread.subject
+            if not subject:
+                artifact = self.thread.artifact
+                if artifact:
+                    subject = getattr(artifact, 'email_subject', '')
         return subject or '(no subject)'
 
     @LazyProperty

http://git-wip-us.apache.org/repos/asf/allura/blob/1bef5beb/Allura/allura/tests/model/test_discussion.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index 2ff36f4..27f83cf 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -541,3 +541,18 @@ def test_spam_num_replies(spam_checker):
     p1 = M.Post(discussion_id=d._id, thread_id=t._id, status='spam')
     p1.spam()
     assert_equal(t.num_replies, 1)
+
+
+def test_deleted_thread_index():
+    d = M.Discussion(shortname='test', name='test')
+    t = M.Thread(discussion_id=d._id, subject='Test Thread')
+    p = M.Post(discussion_id=d._id, thread_id=t._id, status='ok')
+    t.delete()
+    ThreadLocalORMSession.flush_all()
+
+    # re-query, so relationships get reloaded
+    ThreadLocalORMSession.close_all()
+    p = M.Post.query.get(_id=p._id)
+
+    # just make sure this doesn't fail
+    p.index()
\ No newline at end of file


Mime
View raw message