You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2012/12/04 15:26:15 UTC
[25/29] git commit: [#5286] Skip orphaned blog posts in nbhd blog
posts macro
[#5286] Skip orphaned blog posts in nbhd blog posts macro
- If a blog posts app has been deleted, but the post still
exists in mongo, technically it's deleted anyway, and
shouldn't be included in the macro output.
- This is a side-effect of old code that didn't clean up artifacts
properly on tool deletion. The code as it is today *does*
delete artifacts when the tool is deleted.
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f5a220f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f5a220f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f5a220f8
Branch: refs/heads/tv/5382
Commit: f5a220f81ad6efd2505bef2c07a195fe9ffbfc97
Parents: cb6a9e3
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Nov 27 22:59:54 2012 +0000
Committer: Cory Johns <jo...@geek.net>
Committed: Mon Dec 3 20:24:20 2012 +0000
----------------------------------------------------------------------
Allura/allura/lib/macro.py | 3 ++-
Allura/allura/model/artifact.py | 2 ++
2 files changed, 4 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f5a220f8/Allura/allura/lib/macro.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py
index b21714e..4a16226 100644
--- a/Allura/allura/lib/macro.py
+++ b/Allura/allura/lib/macro.py
@@ -109,7 +109,8 @@ def neighborhood_blog_posts(max_number=5, sort='timestamp', summary=False):
author=post.author().display_name,
ago=h.ago(post.timestamp),
description=summary and ' ' or g.markdown.convert(post.text)))
- for post in posts if security.has_access(post, 'read', project=post.app.project)() and
+ for post in posts if post.app and
+ security.has_access(post, 'read', project=post.app.project)() and
security.has_access(post.app.project, 'read', project=post.app.project)())
return output
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f5a220f8/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 3d71aaa..f155bb8 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -186,6 +186,8 @@ class Artifact(MappedClass):
@LazyProperty
def app(self):
+ if not self.app_config:
+ return None
if getattr(c, 'app', None) and c.app.config._id == self.app_config._id:
return c.app
else: