incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [10/11] git commit: [#5650] Fixed threads and posts relation
Date Wed, 26 Jun 2013 22:57:05 GMT
[#5650] Fixed threads and posts relation

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


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

Branch: refs/heads/master
Commit: a36f8c39178ca771a3adccd84b7062b7c76cb50d
Parents: 2be7cd4
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed Jun 26 22:55:56 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed Jun 26 22:56:12 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/discuss.py                 |  4 ++--
 ForgeDiscussion/forgediscussion/model/forum.py | 14 ++++----------
 2 files changed, 6 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a36f8c39/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index a62312f..7699d33 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -55,8 +55,8 @@ class Discussion(Artifact, ActivityObject):
     num_posts = FieldProperty(int, if_missing=0)
     subscriptions = FieldProperty({str: bool})
 
-    threads = RelationProperty('Thread')
-    posts = RelationProperty('Post')
+    threads = RelationProperty('Thread', via='discussion_id')
+    posts = RelationProperty('Post', via='discussion_id')
 
     def __json__(self):
         return dict(

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a36f8c39/ForgeDiscussion/forgediscussion/model/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/model/forum.py b/ForgeDiscussion/forgediscussion/model/forum.py
index 1a4a734..b5206c6 100644
--- a/ForgeDiscussion/forgediscussion/model/forum.py
+++ b/ForgeDiscussion/forgediscussion/model/forum.py
@@ -40,8 +40,8 @@ class Forum(M.Discussion):
     type_s = 'Discussion'
 
     parent_id = FieldProperty(schema.ObjectId, if_missing=None)
-    threads = RelationProperty('ForumThread')
-    posts = RelationProperty('ForumPost')
+    threads = RelationProperty('ForumThread', via='discussion_id')
+    posts = RelationProperty('ForumPost', via='discussion_id')
     members_only = FieldProperty(bool, if_missing=False)
     anon_posts = FieldProperty(bool, if_missing=False)
     monitoring_email = FieldProperty(str, if_missing=None)
@@ -55,10 +55,9 @@ class Forum(M.Discussion):
         return ForumThread
 
     @LazyProperty
-    def all_threads(self):
+    def sorted_threads(self):
         threads = self.thread_class().query.find(dict(discussion_id=self._id))
-        threads = threads.sort([('flags', pymongo.DESCENDING),
-                                ('last_post_date', pymongo.DESCENDING)]).all()
+        threads = threads.sort([('last_post_date', pymongo.DESCENDING)]).all()
         sorted_threads = chain(
             (t for t in threads if 'Announcement' in t.flags),
             (t for t in threads if 'Sticky' in t.flags and 'Announcement' not in t.flags),
@@ -139,11 +138,6 @@ class Forum(M.Discussion):
                     self.app.config.options.mount_point)))
         return super(Forum, self).get_mail_footer(notification, toaddr)
 
-    def __json__(self):
-        json = super(Forum, self).__json__()
-        json.pop('threads')  # it's always empty and useless here
-        return json
-
 class ForumFile(M.File):
     forum_id=FieldProperty(schema.ObjectId)
 


Mime
View raw message