allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [1/2] git commit: [#7026] Handle detached artifacts more gracefully
Date Wed, 15 Jan 2014 19:39:17 GMT
Updated Branches:
  refs/heads/cj/7026 68002e307 -> 7a227dea9 (forced update)


[#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 <cjohns@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/c7e37bf7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c7e37bf7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c7e37bf7

Branch: refs/heads/cj/7026
Commit: c7e37bf7bc8fa4cac6b130a22925e130cf20b5ac
Parents: f824160
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed Jan 15 19:36:51 2014 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed Jan 15 19:36: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/c7e37bf7/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/c7e37bf7/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 884f736..663adf8 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -496,8 +496,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/c7e37bf7/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)
 
 


Mime
View raw message