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

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

Repository: allura
Updated Branches:
  refs/heads/ib/7833 [created] c204f36bd


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

Branch: refs/heads/ib/7833
Commit: c8e40216e628a55de540c34bc26acf521a2c7606
Parents: 0126faa
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Mar 10 20:55:06 2015 +0200
Committer: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Committed: Wed Mar 11 20:03:14 2015 +0200

----------------------------------------------------------------------
 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/c8e40216/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/c8e40216/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)


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

Posted by je...@apache.org.
[#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/c204f36b
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/c204f36b
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/c204f36b

Branch: refs/heads/ib/7833
Commit: c204f36bd2ef86e0a48870693784ce7020f2a6e1
Parents: 8e7a753
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Mar 13 19:09:37 2015 +0200
Committer: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Committed: Fri Mar 13 19:09:37 2015 +0200

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


http://git-wip-us.apache.org/repos/asf/allura/blob/c204f36b/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')
 
 


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

Posted by je...@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/8e7a7532
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/8e7a7532
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/8e7a7532

Branch: refs/heads/ib/7833
Commit: 8e7a7532a9c6b4a457107c580258429e7047c6e1
Parents: c8e4021
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 11 23:28:02 2015 +0200
Committer: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Committed: Wed Mar 11 23:28:02 2015 +0200

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


http://git-wip-us.apache.org/repos/asf/allura/blob/8e7a7532/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()