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/31 15:09:05 UTC

git commit: [#6964] Create commit activity despite unkown user

Updated Branches:
  refs/heads/tv/6964 [created] 1aee97e41


[#6964] Create commit activity despite unkown user

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/1aee97e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1aee97e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1aee97e4

Branch: refs/heads/tv/6964
Commit: 1aee97e41251aabaf5d81563afc321157783ed3d
Parents: a2d2627
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Fri Jan 31 14:08:47 2014 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Jan 31 14:08:47 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo_refresh.py               |  7 +++++--
 Allura/allura/model/timeline.py                   | 13 ++++++++++++-
 ForgeActivity/forgeactivity/templates/macros.html |  6 +++++-
 3 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1aee97e4/Allura/allura/model/repo_refresh.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py
index d5ba927..d364d2c 100644
--- a/Allura/allura/model/repo_refresh.py
+++ b/Allura/allura/model/repo_refresh.py
@@ -36,6 +36,7 @@ from allura.model.repo import CommitRunDoc
 from allura.model.repo import Commit, Tree, LastCommit, ModelCache
 from allura.model.index import ArtifactReferenceDoc, ShortlinkDoc
 from allura.model.auth import User
+from allura.model.timeline import TransientActor
 
 log = logging.getLogger(__name__)
 
@@ -140,8 +141,10 @@ 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])
+            actor = user or TransientActor(
+                    activity_name=new.committed.name or new.committed.emai)
+            g.director.create_activity(actor, '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)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1aee97e4/Allura/allura/model/timeline.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/timeline.py b/Allura/allura/model/timeline.py
index be538a2..63cbd83 100644
--- a/Allura/allura/model/timeline.py
+++ b/Allura/allura/model/timeline.py
@@ -47,7 +47,8 @@ class Director(ActivityDirector):
         super(Director, self).create_activity(actor, verb, obj,
                                               target=target, related_nodes=related_nodes)
         # aggregate actor and follower's timelines
-        create_timelines.post(actor.node_id)
+        if actor.node_id:
+            create_timelines.post(actor.node_id)
         # aggregate project and follower's timelines
         for node in [obj, target] + (related_nodes or []):
             if isinstance(node, Project):
@@ -99,6 +100,16 @@ class ActivityObject(ActivityObjectBase):
         return security.has_access(self, perm, user, self.project)
 
 
+class TransientActor(NodeBase, ActivityObjectBase):
+    """An activity actor which is not a persistent Node in the network.
+
+    """
+    def __init__(self, activity_name):
+        NodeBase.__init__(self)
+        ActivityObjectBase.__init__(self)
+        self.activity_name = activity_name
+
+
 def perm_check(user):
     def _perm_check(activity):
         """Return True if c.user has 'read' access to this activity,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1aee97e4/ForgeActivity/forgeactivity/templates/macros.html
----------------------------------------------------------------------
diff --git a/ForgeActivity/forgeactivity/templates/macros.html b/ForgeActivity/forgeactivity/templates/macros.html
index c60582e..f3bac05 100644
--- a/ForgeActivity/forgeactivity/templates/macros.html
+++ b/ForgeActivity/forgeactivity/templates/macros.html
@@ -18,7 +18,11 @@
 -#}
 
 {% macro activity_obj(o) %}
-  <a href="{{o.activity_url}}">{{o.activity_name}}</a>
+  {% if o.activity_url %}
+    <a href="{{o.activity_url}}">{{o.activity_name}}</a>
+  {% else %}
+    {{o.activity_name}}
+  {% endif %}
 {% endmacro %}
 
 {% macro icon(o, size, className) -%}