You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/03/19 19:40:47 UTC

[1/3] allura git commit: [#7833] ticket:741 Strip email addresses in EmailAddress collection as well

Repository: allura
Updated Branches:
  refs/heads/master 269703c5c -> 970739581


[#7833] ticket:741 Strip email addresses in EmailAddress collection as well


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

Branch: refs/heads/master
Commit: 97073958155edf5af5b245d4feb31f7fa35bccb4
Parents: 27f9c9f
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Mar 13 19:09:37 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 18:37:45 2015 +0000

----------------------------------------------------------------------
 Allura/allura/scripts/trim_emails.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/97073958/Allura/allura/scripts/trim_emails.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/trim_emails.py b/Allura/allura/scripts/trim_emails.py
index 0ce4caa..f847224 100644
--- a/Allura/allura/scripts/trim_emails.py
+++ b/Allura/allura/scripts/trim_emails.py
@@ -17,6 +17,8 @@
 
 import logging
 
+from ming.orm import session
+
 from allura.scripts import ScriptTask
 from allura import model as M
 from allura.lib.utils import chunked_find
@@ -37,6 +39,14 @@ class TrimEmails(ScriptTask):
                 if u.preferences.email_address is not None:
                     u.preferences.email_address = M.EmailAddress.canonical(
                         u.preferences.email_address)
+                session(u).flush(u)
+        for chunk in chunked_find(M.EmailAddress, {}):
+            for a in chunk:
+                log.info('Trimming email address entry %s', a.email)
+                a.email = M.EmailAddress.canonical(a.email)
+                session(a).flush(a)
+        M.main_orm_session.flush()
+        M.main_orm_session.clear()
         log.info('Finished trimming emails')
 
 


[3/3] allura git commit: [#7833] ticket:741 Added .strip() to EmailAddress.canonical

Posted by he...@apache.org.
[#7833] ticket:741 Added .strip() to EmailAddress.canonical


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

Branch: refs/heads/master
Commit: c2673b61721ea0b0d042a2a5dad802ca0f884249
Parents: 269703c
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Mar 10 20:55:06 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 18:37:45 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py            | 2 +-
 Allura/allura/tests/model/test_auth.py | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/c2673b61/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 0b92443..f7e8c91 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -169,7 +169,7 @@ class EmailAddress(MappedClass):
         if mo:
             addr = mo.group(1)
         if '@' in addr:
-            user, domain = addr.split('@')
+            user, domain = addr.strip().split('@')
             return '%s@%s' % (user, domain.lower())
         else:
             return None

http://git-wip-us.apache.org/repos/asf/allura/blob/c2673b61/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 12db982..eb7416c 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -103,6 +103,8 @@ def test_email_address_canonical():
                  'nobody@example.com')
     assert_equal(M.EmailAddress.canonical('I Am Nobody <no...@example.com>'),
                  'nobody@example.com')
+    assert_equal(M.EmailAddress.canonical('  nobody@example.com\t'),
+                 'nobody@example.com')
     assert_equal(M.EmailAddress.canonical('invalid'), None)
 
 @with_setup(setUp)


[2/3] allura git commit: [#7833] ticket:741 Added script for trimming user emails

Posted by he...@apache.org.
[#7833] ticket:741 Added script for trimming user emails


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

Branch: refs/heads/master
Commit: 27f9c9fff47dd4ff9bca68198d93a8c32270ab88
Parents: c2673b6
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 11 23:28:02 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 18:37:45 2015 +0000

----------------------------------------------------------------------
 Allura/allura/scripts/trim_emails.py | 44 +++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/27f9c9ff/Allura/allura/scripts/trim_emails.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/trim_emails.py b/Allura/allura/scripts/trim_emails.py
new file mode 100644
index 0000000..0ce4caa
--- /dev/null
+++ b/Allura/allura/scripts/trim_emails.py
@@ -0,0 +1,44 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+import logging
+
+from allura.scripts import ScriptTask
+from allura import model as M
+from allura.lib.utils import chunked_find
+
+
+log = logging.getLogger(__name__)
+
+
+class TrimEmails(ScriptTask):
+
+    @classmethod
+    def execute(cls, options):
+        for chunk in chunked_find(M.User, {}):
+            for u in chunk:
+                log.info('Trimming emails for user %s', u.username)
+                new_addresses = [M.EmailAddress.canonical(addr) for addr in u.email_addresses]
+                u.email_addresses = new_addresses
+                if u.preferences.email_address is not None:
+                    u.preferences.email_address = M.EmailAddress.canonical(
+                        u.preferences.email_address)
+        log.info('Finished trimming emails')
+
+
+if __name__ == '__main__':
+    TrimEmails.main()