allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject git commit: [#7752] ticket:670 Fix error when indexing users
Date Fri, 17 Oct 2014 12:25:18 GMT
Repository: allura
Updated Branches:
  refs/heads/je/7752 [created] 4615e22aa


[#7752] ticket:670 Fix error when indexing users


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

Branch: refs/heads/je/7752
Commit: 4615e22aa25c7e1c0203c2a3357dec363019bbdf
Parents: 10472d1
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri Oct 17 14:18:47 2014 +0300
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Fri Oct 17 15:24:31 2014 +0300

----------------------------------------------------------------------
 Allura/allura/model/auth.py            |  6 +++---
 Allura/allura/tests/model/test_auth.py | 10 ++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/4615e22a/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 32f9b17..439c3d2 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -297,7 +297,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
             url_s=self.url(),
             type_s=self.type_s,
             username_s=self.username,
-            email_addresses_t=' '.join(self.email_addresses),
+            email_addresses_t=' '.join([e for e in self.email_addresses if e]),
             last_password_updated_dt=self.last_password_updated,
             disabled_b=self.disabled,
             results_per_page_i=self.get_pref('results_per_page'),
@@ -310,9 +310,9 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
             localization_s=localization,
             timezone_s=self.get_pref('timezone'),
             socialnetworks_t=socialnetworks,
-            telnumbers_t=' '.join(self.get_pref('telnumbers')),
+            telnumbers_t=' '.join([t for t in self.get_pref('telnumbers') if t]),
             skypeaccount_s=self.get_pref('skypeaccount'),
-            webpages_t=' '.join(self.get_pref('webpages')),
+            webpages_t=' '.join([p for p in self.get_pref('webpages') if p]),
             skills_t=' '.join([s['skill'].fullpath for s in self.get_skills() if s.get('skill')]),
             last_access_login_date_dt=self.last_access['login_date'],
             last_access_login_ip_s=self.last_access['login_ip'],

http://git-wip-us.apache.org/repos/asf/allura/blob/4615e22a/Allura/allura/tests/model/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_auth.py b/Allura/allura/tests/model/test_auth.py
index 3d6b69e..2b05672 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -326,3 +326,13 @@ def test_user_index():
     assert_in('last_access_session_ua_t', idx)
     # provided bby auth provider
     assert_in('user_registration_date_dt', idx)
+
+@with_setup(setUp)
+def test_user_index_none_values():
+    c.user.email_addresses = [None]
+    c.user.set_pref('telnumbers', [None])
+    c.user.set_pref('webpages', [None])
+    idx = c.user.index()
+    assert_equal(idx['email_addresses_t'], '')
+    assert_equal(idx['telnumbers_t'], '')
+    assert_equal(idx['webpages_t'], '')


Mime
View raw message