allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject allura git commit: [#8167] allow blog post edits & deletes when feed_item does not exist (eg. if tool/proj was private); create feed item upon re-edit if needed
Date Mon, 09 Oct 2017 15:13:26 GMT
Repository: allura
Updated Branches:
  refs/heads/db/8167 [created] 875f714a6


[#8167] allow blog post edits & deletes when feed_item does not exist (eg. if tool/proj
was private); create feed item upon re-edit if needed


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

Branch: refs/heads/db/8167
Commit: 875f714a67289cd8747e9f783190e3854715a2c8
Parents: c6a8804
Author: Dave Brondsema <dave@brondsema.net>
Authored: Mon Oct 9 11:12:56 2017 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Mon Oct 9 11:12:56 2017 -0400

----------------------------------------------------------------------
 ForgeBlog/forgeblog/model/blog.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/875f714a/ForgeBlog/forgeblog/model/blog.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/model/blog.py b/ForgeBlog/forgeblog/model/blog.py
index bafd1ab..67b45b6 100644
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -258,8 +258,12 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
                     c.user.username, self.title)
             elif v2.state == 'published':
                 feed_item = self.feed_item()
-                feed_item.title = self.title
-                feed_item.description = g.markdown.convert(self.text)
+                if feed_item:
+                    feed_item.title = self.title
+                    feed_item.description = g.markdown.convert(self.text)
+                else:
+                    M.Feed.post(self, self.title, self.text, author=self.author(),
+                                pubdate=self.get_version(1).timestamp)
                 if v1.title != v2.title:
                     activity('renamed', self)
                     subject = '%s renamed post %s to %s' % (
@@ -269,7 +273,9 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
                     subject = '%s modified post %s' % (
                         c.user.username, self.title)
             elif v1.state == 'published' and v2.state == 'draft':
-                self.feed_item().delete()
+                feed_item = self.feed_item()
+                if feed_item:
+                    feed_item.delete()
         else:
             description = self.text
             subject = '%s created post %s' % (
@@ -310,7 +316,9 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
                                 link=self.link_regex)
 
     def delete(self):
-        self.feed_item().delete()
+        feed_item = self.feed_item()
+        if feed_item:
+            feed_item.delete()
         super(BlogPost, self).delete()
 
 


Mime
View raw message