incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [3/5] git commit: [#5013] ticket:196 Set proper pubDate for news in RSS feed
Date Wed, 31 Oct 2012 17:34:54 GMT
[#5013] ticket:196 Set proper pubDate for news in RSS feed


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

Branch: refs/heads/cj/5005
Commit: 11727510fade8195bfe6e3fa2caa09f6a36b798d
Parents: beeb0e7
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Tue Oct 30 13:05:07 2012 +0400
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Wed Oct 31 16:22:19 2012 +0000

----------------------------------------------------------------------
 Allura/allura/model/artifact.py                  |    3 +-
 ForgeBlog/forgeblog/model/blog.py                |    4 +-
 ForgeBlog/forgeblog/tests/unit/test_blog_post.py |   21 +++++++++++++++++
 3 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/11727510/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 197ed86..29fe828 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -619,7 +619,7 @@ class Feed(MappedClass):
 
 
     @classmethod
-    def post(cls, artifact, title=None, description=None, author=None, author_link=None,
author_name=None):
+    def post(cls, artifact, title=None, description=None, author=None, author_link=None,
author_name=None, pubdate=datetime.utcnow()):
         """
         Create a Feed item.  Returns the item.
         But if anon doesn't have read access, create does not happen and None is returned
@@ -649,6 +649,7 @@ class Feed(MappedClass):
             description=description,
             link=artifact.url(),
             author_name=author_name,
+            pubdate=pubdate,
             author_link=author_link or author.url())
         return item
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/11727510/ForgeBlog/forgeblog/model/blog.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/model/blog.py b/ForgeBlog/forgeblog/model/blog.py
index 50e8e1c..0c7aec4 100644
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -215,7 +215,7 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
             description = diff
             if v1.state != 'published' and v2.state == 'published':
                 activity('created', self)
-                M.Feed.post(self, self.title, self.text, author=self.author())
+                M.Feed.post(self, self.title, self.text, author=self.author(), pubdate=self.get_version(1).timestamp)
                 description = self.text
                 subject = '%s created post %s' % (
                     c.user.username, self.title)
@@ -233,7 +233,7 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
                 c.user.username, self.title)
             if self.state == 'published':
                 activity('created', self)
-                M.Feed.post(self, self.title, self.text, author=self.author())
+                M.Feed.post(self, self.title, self.text, author=self.author(), pubdate=self.timestamp)
         if self.state == 'published':
             M.Notification.post(
                 artifact=self, topic='metadata', text=description, subject=subject)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/11727510/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/unit/test_blog_post.py b/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
index 9dcba4f..c9915c4 100644
--- a/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
+++ b/ForgeBlog/forgeblog/tests/unit/test_blog_post.py
@@ -1,12 +1,33 @@
 from datetime import datetime
 from nose.tools import assert_equal
+from pylons import c
 
 from forgeblog import model as M
 from forgeblog.tests.unit import BlogTestWithModel
+from allura.model import Feed
 
 def wrapped(s):
     return '<div class="markdown_content"><p>%s</p></div>' % s
 
+class TestFeed(BlogTestWithModel):
+    def testd(self):
+        post = M.BlogPost()
+        post.title = 'test'
+        post.text = 'test message'
+        post.state = 'published'
+        post.timestamp = datetime(2012, 10, 29, 9, 57, 21, 465000)
+        post.neighborhood_id = c.project.neighborhood_id
+        post.make_slug()
+        post.commit()
+        f = Feed.post(
+            post,
+            title=post.title,
+            description=post.text,
+            author=post.author(),
+            pubdate=post.timestamp)
+        assert_equal(f.pubdate, datetime(2012, 10, 29, 9, 57, 21, 465000))
+
+
 class TestHtmlPreview(BlogTestWithModel):
     def _make_post(self, text):
         post = M.BlogPost()


Mime
View raw message