Feed correct, update function add.
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 3d798fd..3a84f78 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -823,17 +823,21 @@
artifact_reference = FieldProperty(S.Deprecated)
@classmethod
+ def has_access(cls, artifact):
+ from allura import model as M
+ anon = M.User.anonymous()
+ if not security.has_access(artifact, 'read', user=anon):
+ return False
+ if not security.has_access(c.project, 'read', user=anon):
+ return False
+
+ @classmethod
def post(cls, artifact, title=None, description=None, author=None, author_link=None, author_name=None, pubdate=None, link=None, **kw):
"""
Create a Feed item. Returns the item.
But if anon doesn't have read access, create does not happen and None is returned
"""
- # TODO: fix security system so we can do this correctly and fast
- from allura import model as M
- anon = M.User.anonymous()
- if not security.has_access(artifact, 'read', user=anon):
- return
- if not security.has_access(c.project, 'read', user=anon):
+ if Feed.has_access(artifact) == False:
return
idx = artifact.index()
if author is None:
@@ -867,6 +871,19 @@
return item
@classmethod
+ def update(cls, artifact, title=None, description=None, author=None, author_link=None, author_name=None, pubdate=None, link=None, **kw):
+ """
+ For a blog post which is present already but to be updated.
+ """
+ if Feed.has_access(artifact) == False:
+ return
+ # Modify the previous version.
+ v1 = Feed.query.find({'ref_id': artifact.index_id()}).first()
+ v1.title = title
+ v1.description = description
+ return v1
+
+ @classmethod
def feed(cls, q, feed_type, title, link, description,
since=None, until=None, page=None, limit=None):
"Produces webhelper.feedgenerator Feed"
diff --git a/ForgeBlog/forgeblog/model/blog.py b/ForgeBlog/forgeblog/model/blog.py
index 818e207..9b35dc3 100644
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -258,10 +258,14 @@
activity('renamed', self)
subject = '%s renamed post %s to %s' % (
c.user.username, v1.title, v2.title)
+ M.Feed.update(self, self.title, self.text, author=self.author(),
+ pubdate=self.get_version(1).timestamp)
else:
activity('modified', self)
subject = '%s modified post %s' % (
c.user.username, self.title)
+ M.Feed.update(self, self.title, self.text, author=self.author(),
+ pubdate=self.get_version(1).timestamp)
else:
description = self.text
subject = '%s created post %s' % (