allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject allura git commit: [#8171] changes in user's full name will now change activity record entries too
Date Thu, 04 Jan 2018 17:49:49 GMT
Repository: allura
Updated Branches:
  refs/heads/db/8171 [created] cfa73f775


[#8171] changes in user's full name will now change activity record entries too


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/cfa73f77
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/cfa73f77
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/cfa73f77

Branch: refs/heads/db/8171
Commit: cfa73f77553e511d8ee4ae0816cea60853da1701
Parents: 49a4818
Author: Dave Brondsema <dave@brondsema.net>
Authored: Thu Jan 4 12:49:38 2018 -0500
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Thu Jan 4 12:49:38 2018 -0500

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py           |  4 ++++
 Allura/allura/tasks/activity_tasks.py | 12 ++++++++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/cfa73f77/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index aafe236..45bc309 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -54,6 +54,7 @@ from allura.lib import helpers as h
 from allura.lib import security
 from allura.lib import exceptions as forge_exc
 from allura.lib import utils
+from allura.tasks import activity_tasks
 from allura.tasks.index_tasks import solr_del_project_artifacts
 
 log = logging.getLogger(__name__)
@@ -1489,6 +1490,9 @@ class LocalUserPreferencesProvider(UserPreferencesProvider):
             return getattr(user, pref_name)
 
     def set_pref(self, user, pref_name, pref_value):
+        if pref_name == 'display_name' and asbool(config.get('activitystream.recording.enabled',
False)):
+            activity_tasks.change_user_name.post(user._id, pref_value)
+
         if pref_name in user.preferences:
             user.preferences[pref_name] = pref_value
         else:

http://git-wip-us.apache.org/repos/asf/allura/blob/cfa73f77/Allura/allura/tasks/activity_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/activity_tasks.py b/Allura/allura/tasks/activity_tasks.py
index 26ac02a..312d9ec 100644
--- a/Allura/allura/tasks/activity_tasks.py
+++ b/Allura/allura/tasks/activity_tasks.py
@@ -16,6 +16,7 @@
 #       under the License.
 
 from pylons import app_globals as g
+from activitystream.storage.mingstorage import Activity
 
 from allura.lib.decorators import task
 
@@ -23,3 +24,14 @@ from allura.lib.decorators import task
 @task
 def create_timelines(node_id):
     g.director.create_timelines(node_id)
+
+
+@task
+def change_user_name(user_id, new_name):
+    Activity.query.update(
+        {'actor.node_id': "User:{}".format(user_id)},
+        {'$set': {
+            "actor.activity_name": new_name,
+        }},
+        multi=True
+    )


Mime
View raw message