You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/12/06 22:24:36 UTC

[1/3] git commit: [#6941] Check commit activity access against original tool if possible.

Updated Branches:
  refs/heads/master 237417639 -> 192a5a054


[#6941] Check commit activity access against original tool if possible.

Signed-off-by: Tim Van Steenburgh <tv...@gmail.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/192a5a05
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/192a5a05
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/192a5a05

Branch: refs/heads/master
Commit: 192a5a054433a9a16fdb97a42709523293ddf3e4
Parents: 5c312e4
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Thu Dec 5 22:16:30 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Dec 6 21:24:26 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/discuss.py  |  2 +-
 Allura/allura/model/repo.py     | 19 +++++++++++++++++--
 Allura/allura/model/timeline.py |  4 ++--
 3 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/192a5a05/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index df55ac9..7b4f306 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -476,7 +476,7 @@ class Post(Message, VersionedArtifact, ActivityObject):
     def activity_name(self):
         return 'a comment'
 
-    def has_activity_access(self, perm, user):
+    def has_activity_access(self, perm, user, activity):
         """Return True if user has perm access to this object, otherwise
         return False.
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/192a5a05/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 1ff6641..8918b02 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -37,8 +37,10 @@ from ming.orm import mapper, session
 
 from allura.lib import utils
 from allura.lib import helpers as h
+from allura.lib.security import has_access
 
 from .auth import User
+from .project import AppConfig, Project
 from .session import main_doc_session, project_doc_session
 from .session import repository_orm_session
 from .timeline import ActivityObject
@@ -174,10 +176,23 @@ class Commit(RepoObject, ActivityObject):
     def activity_name(self):
         return self.shorthand_id()
 
-    def has_activity_access(self, perm, user):
-        """Commits have no ACLs and are therefore always viewable by any user.
+    @property
+    def activity_extras(self):
+        d = ActivityObject.activity_extras.fget(self)
+        d.update(summary=self.summary)
+        if self.repo:
+            d.update(app_config_id=self.repo.app.config._id)
+        return d
 
+    def has_activity_access(self, perm, user, activity):
+        """
+        Commits have no ACLs and are therefore always viewable by any user, if
+        they have access to the tool.
         """
+        app_config_id = activity.obj.activity_extras.get('app_config_id')
+        if app_config_id:
+            app_config = AppConfig.query.get(_id=app_config_id)
+            return has_access(app_config, perm, user)
         return True
 
     def set_context(self, repo):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/192a5a05/Allura/allura/model/timeline.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/timeline.py b/Allura/allura/model/timeline.py
index a80e5ba..b45118e 100644
--- a/Allura/allura/model/timeline.py
+++ b/Allura/allura/model/timeline.py
@@ -51,7 +51,7 @@ class ActivityObject(base.ActivityObjectBase):
         """
         return "%s:%s" % (self.__class__.__name__, self._id)
 
-    def has_activity_access(self, perm, user):
+    def has_activity_access(self, perm, user, activity):
         """Return True if user has perm access to this object, otherwise
         return False.
         """
@@ -74,5 +74,5 @@ def perm_check(user):
         except bson.errors.InvalidId:
             pass
         obj = cls.query.get(_id=_id)
-        return obj and obj.has_activity_access('read', user)
+        return obj and obj.has_activity_access('read', user, activity)
     return _perm_check


[2/3] git commit: [#6941] Don't break on svn commit _id, which contains ':'

Posted by br...@apache.org.
[#6941] Don't break on svn commit _id, which contains ':'

Signed-off-by: Tim Van Steenburgh <tv...@gmail.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/5c312e46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5c312e46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5c312e46

Branch: refs/heads/master
Commit: 5c312e46f7ae2f59ff91c9faf9f0f5e0f207bfd5
Parents: 785bb17
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Wed Dec 4 01:18:57 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Dec 6 21:24:26 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/timeline.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5c312e46/Allura/allura/model/timeline.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/timeline.py b/Allura/allura/model/timeline.py
index 38550b8..a80e5ba 100644
--- a/Allura/allura/model/timeline.py
+++ b/Allura/allura/model/timeline.py
@@ -67,7 +67,7 @@ def perm_check(user):
         if not extras_dict: return True
         allura_id = extras_dict.get('allura_id')
         if not allura_id: return True
-        classname, _id = allura_id.split(':')
+        classname, _id = allura_id.split(':', 1)
         cls = Mapper.by_classname(classname).mapped_class
         try:
             _id = bson.ObjectId(_id)


[3/3] git commit: [#6941] Create activity events for commits

Posted by br...@apache.org.
[#6941] Create activity events for commits

Signed-off-by: Tim Van Steenburgh <tv...@gmail.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/785bb177
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/785bb177
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/785bb177

Branch: refs/heads/master
Commit: 785bb177d0366e52d5acb1d6341e46fd93a18739
Parents: 2374176
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Wed Dec 4 00:59:20 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Dec 6 21:24:26 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo.py         | 13 ++++++++++++-
 Allura/allura/model/repo_refresh.py |  2 ++
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/785bb177/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 3b4feca..1ff6641 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -41,6 +41,7 @@ from allura.lib import helpers as h
 from .auth import User
 from .session import main_doc_session, project_doc_session
 from .session import repository_orm_session
+from .timeline import ActivityObject
 
 log = logging.getLogger(__name__)
 
@@ -164,11 +165,21 @@ class RepoObject(object):
             r = cls.query.get(_id=id)
         return r, isnew
 
-class Commit(RepoObject):
+class Commit(RepoObject, ActivityObject):
     type_s = 'Commit'
     # Ephemeral attrs
     repo=None
 
+    @property
+    def activity_name(self):
+        return self.shorthand_id()
+
+    def has_activity_access(self, perm, user):
+        """Commits have no ACLs and are therefore always viewable by any user.
+
+        """
+        return True
+
     def set_context(self, repo):
         self.repo = repo
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/785bb177/Allura/allura/model/repo_refresh.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py
index 52855b5..2a8af51 100644
--- a/Allura/allura/model/repo_refresh.py
+++ b/Allura/allura/model/repo_refresh.py
@@ -137,6 +137,8 @@ def refresh_repo(repo, all_commits=False, notify=True, new_clone=False):
                 user = User.by_username(new.committed.name)
             if user is not None:
                 g.statsUpdater.newCommit(new, repo.app_config.project, user)
+                g.director.create_activity(user, 'committed', new,
+                        related_nodes=[repo.app_config.project])
 
     log.info('Refresh complete for %s', repo.full_fs_path)
     g.post_event('repo_refreshed', len(commit_ids), all_commits, new_clone)