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 2014/01/21 23:09:21 UTC

[06/22] git commit: [#7026] Handle detached artifacts more gracefully

[#7026] Handle detached artifacts more gracefully

On the off chance that an Artifact or AppConfig gets detached
from its project, we want to handle it a bit more gracefully.
This situtation shouldn't really come up in production, as it
means the data is bad, but it can happen on a sandbox.

Signed-off-by: Cory Johns <cj...@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/84309dd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/84309dd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/84309dd7

Branch: refs/heads/tv/6393
Commit: 84309dd77d32d07bbfe19d6745c5a4c6a46b71c9
Parents: 3d7741f
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Jan 15 19:36:51 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Jan 15 20:06:55 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/artifact.py | 2 +-
 Allura/allura/model/discuss.py  | 4 ++++
 Allura/allura/model/timeline.py | 2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/84309dd7/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 8a01c42..56c7643 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -265,7 +265,7 @@ class Artifact(MappedClass):
         this Artifact belongs.
 
         """
-        return self.app_config.project
+        return getattr(self.app_config, 'project', None)
 
     @property
     def project_id(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/84309dd7/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 9d27470..4303c66 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -499,8 +499,12 @@ class Post(Message, VersionedArtifact, ActivityObject):
         not have access to a 'comment' activity unless he also has access to
         the artifact on which it was posted (if there is one).
         """
+        if self.project is None:
+            return False
         artifact_access = True
         if self.thread.artifact:
+            if self.thread.artifact.project is None:
+                return False
             artifact_access = security.has_access(self.thread.artifact, perm,
                                                   user, self.thread.artifact.project)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/84309dd7/Allura/allura/model/timeline.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/timeline.py b/Allura/allura/model/timeline.py
index 3487b9c..7b350aa 100644
--- a/Allura/allura/model/timeline.py
+++ b/Allura/allura/model/timeline.py
@@ -89,6 +89,8 @@ class ActivityObject(ActivityObjectBase):
         """Return True if user has perm access to this object, otherwise
         return False.
         """
+        if self.project is None:
+            return False
         return security.has_access(self, perm, user, self.project)