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 2014/11/19 15:01:12 UTC

[01/26] allura git commit: [#7789] ticket:680 Return more fields in ticket API search results

Repository: allura
Updated Branches:
  refs/heads/ib/7794 9aba981f8 -> d62cd945e (forced update)


[#7789] ticket:680 Return more fields in ticket API search results


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

Branch: refs/heads/ib/7794
Commit: 4d9f918a67ad5ca5078a7534b61b1fddadf6f603
Parents: 9151524
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Nov 10 10:56:01 2014 +0000
Committer: Alexander Luberg <al...@slashdotmedia.com>
Committed: Fri Nov 14 07:16:40 2014 -0800

----------------------------------------------------------------------
 .../forgetracker/tests/functional/test_rest.py  | 43 +++++++++++++-------
 ForgeTracker/forgetracker/tracker_main.py       | 10 ++++-
 2 files changed, 36 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/4d9f918a/ForgeTracker/forgetracker/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_rest.py b/ForgeTracker/forgetracker/tests/functional/test_rest.py
index 455cff5..7c650be 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_rest.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_rest.py
@@ -191,23 +191,31 @@ class TestRestDiscussion(TestTrackerApiBase):
 
 class TestRestSearch(TestTrackerApiBase):
 
+    @property
+    def ticket(self):
+        return TM.Ticket(
+            ticket_num=5,
+            summary='our test ticket',
+            status='open',
+            labels=['tiny', 'minor'])
+
     @patch('forgetracker.model.Ticket.paged_search')
     def test_no_criteria(self, paged_search):
-        paged_search.return_value = dict(tickets=[
-            TM.Ticket(ticket_num=5, summary='our test ticket'),
-        ])
+        paged_search.return_value = dict(tickets=[self.ticket])
         r = self.api_get('/rest/p/test/bugs/search')
         assert_equal(r.status_int, 200)
-        assert_equal(r.json, {'tickets': [
-            {'summary': 'our test ticket', 'ticket_num': 5},
-        ]})
+        assert_equal(r.json['tickets'][0]['summary'], 'our test ticket')
+        assert_equal(r.json['tickets'][0]['ticket_num'], 5)
+        assert_equal(r.json['tickets'][0]['status'], 'open')
+        assert_equal(r.json['tickets'][0]['labels'], ['tiny', 'minor'])
+        assert 'description' not in r.json
+        assert 'discussion_thread' not in r.json
 
     @patch('forgetracker.model.Ticket.paged_search')
     def test_some_criteria(self, paged_search):
         q = 'labels:testing && status:open'
-        paged_search.return_value = dict(tickets=[
-            TM.Ticket(ticket_num=5, summary='our test ticket'),
-        ],
+        paged_search.return_value = dict(
+            tickets=[self.ticket],
             sort='status',
             limit=2,
             count=1,
@@ -217,9 +225,14 @@ class TestRestSearch(TestTrackerApiBase):
         r = self.api_get('/rest/p/test/bugs/search',
                          q=q, sort='status', limit='2')
         assert_equal(r.status_int, 200)
-        assert_equal(r.json, {'limit': 2, 'q': q, 'sort': 'status', 'count': 1,
-                              'page': 0, 'tickets': [
-                                  {'summary': 'our test ticket',
-                                   'ticket_num': 5},
-                              ]
-                              })
+        assert_equal(r.json['limit'], 2)
+        assert_equal(r.json['q'], q)
+        assert_equal(r.json['sort'], 'status')
+        assert_equal(r.json['count'], 1)
+        assert_equal(r.json['page'], 0)
+        assert_equal(r.json['tickets'][0]['summary'], 'our test ticket')
+        assert_equal(r.json['tickets'][0]['ticket_num'], 5)
+        assert_equal(r.json['tickets'][0]['status'], 'open')
+        assert_equal(r.json['tickets'][0]['labels'], ['tiny', 'minor'])
+        assert 'description' not in r.json
+        assert 'discussion_thread' not in r.json

http://git-wip-us.apache.org/repos/asf/allura/blob/4d9f918a/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index d37b5b1..fd8917e 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1717,10 +1717,16 @@ class RootRestController(BaseController):
 
     @expose('json:')
     def search(self, q=None, limit=100, page=0, sort=None, **kw):
+        def _convert_ticket(t):
+            t = t.__json__()
+            # just pop out all the heavy stuff
+            for field in ['description', 'discussion_thread']:
+                t.pop(field, None)
+            return t
+
         results = TM.Ticket.paged_search(
             c.app.config, c.user, q, limit, page, sort, show_deleted=False)
-        results['tickets'] = [dict(ticket_num=t.ticket_num, summary=t.summary)
-                              for t in results['tickets']]
+        results['tickets'] = map(_convert_ticket, results['tickets'])
         return results
 
     @expose()


[03/26] allura git commit: [#7704] ticket:662 Added email field to registration form

Posted by je...@apache.org.
[#7704] ticket:662 Added email field to registration form


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

Branch: refs/heads/ib/7794
Commit: edb3d5d0be87dc85268aff2c2b37dfbcd7dde442
Parents: 4d9f918
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 16:35:22 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:01 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py  | 8 ++++++--
 Allura/allura/lib/widgets/forms.py | 4 ++++
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/edb3d5d0/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 94a97cc..e3798f1 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -220,14 +220,18 @@ class AuthController(BaseController):
     @expose()
     @require_post()
     @validate(F.registration_form, error_handler=create_account)
-    def save_new(self, display_name=None, username=None, pw=None, **kw):
+    def save_new(self, display_name=None, username=None, pw=None, email=None, **kw):
         if not asbool(config.get('auth.allow_user_registration', True)):
             raise wexc.HTTPNotFound()
         user = M.User.register(
             dict(username=username,
                  display_name=display_name,
-                 password=pw))
+                 password=pw,
+                 email_addresses=[email]))
         plugin.AuthenticationProvider.get(request).login(user)
+        em = M.EmailAddress.create(email)
+        em.claimed_by_user_id = user._id
+        em.send_verification_link()
         flash('User "%s" registered' % username)
         redirect('/')
 

http://git-wip-us.apache.org/repos/asf/allura/blob/edb3d5d0/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 89535fb..3d243e2 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -755,6 +755,10 @@ class RegistrationForm(ForgeForm):
                 label='Displayed Name',
                 validator=fev.UnicodeString(not_empty=True)),
             username,
+            ew.TextField(
+                name='email',
+                label='Your e-mail',
+                validator=fev.Email()),
             ew.PasswordField(
                 name='pw',
                 label='New Password',


[23/26] allura git commit: [#7794] ticket:686 Use page size pref on tracker main page

Posted by je...@apache.org.
[#7794] ticket:686 Use page size pref on tracker main page


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

Branch: refs/heads/ib/7794
Commit: 8811b277333dd529f7da824cd44bfd3d4d7029c0
Parents: 86f76d5
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Nov 18 11:50:23 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 18 11:50:23 2014 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/tracker_main.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/8811b277/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 9cc3596..b38bf1d 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -641,7 +641,7 @@ class RootController(BaseController, FeedController):
     @expose('jinja:forgetracker:templates/tracker/index.html')
     @validate(dict(deleted=validators.StringBool(if_empty=False),
                    filter=V.JsonConverter(if_empty={})))
-    def index(self, limit=25, columns=None, page=0, sort='ticket_num desc', deleted=False, filter=None, **kw):
+    def index(self, limit=None, columns=None, page=0, sort='ticket_num desc', deleted=False, filter=None, **kw):
         show_deleted = [False]
         if deleted and has_access(c.app, 'delete'):
             show_deleted = [False, True]
@@ -652,7 +652,7 @@ class RootController(BaseController, FeedController):
                                                  c.app.globals.not_closed_mongo_query,
                                                  c.app.globals.not_closed_query,
                                                  filter,
-                                                 sort=sort, limit=int(limit), page=page,
+                                                 sort=sort, limit=limit, page=page,
                                                  deleted={'$in': show_deleted},
                                                  show_deleted=deleted, **kw)
 


[02/26] allura git commit: [#7704] ticket:662 Set pending status on registration

Posted by je...@apache.org.
[#7704] ticket:662 Set pending status on registration


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

Branch: refs/heads/ib/7794
Commit: 257c383dfbb16a868f5c1af808006f15ffc67aff
Parents: edb3d5d
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 18:57:09 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:01 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py           |  3 ++-
 Allura/allura/model/auth.py                 |  1 +
 Allura/allura/tests/functional/test_auth.py | 11 ++++++++---
 3 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/257c383d/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index e3798f1..5d966a1 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -227,7 +227,8 @@ class AuthController(BaseController):
             dict(username=username,
                  display_name=display_name,
                  password=pw,
-                 email_addresses=[email]))
+                 email_addresses=[email],
+                 pending=True))
         plugin.AuthenticationProvider.get(request).login(user)
         em = M.EmailAddress.create(email)
         em.claimed_by_user_id = user._id

http://git-wip-us.apache.org/repos/asf/allura/blob/257c383d/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 74fcd24..ee2793b 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -248,6 +248,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
     tool_preferences = FieldProperty(S.Deprecated)
     tool_data = FieldProperty({str: {str: None}})  # entry point: prefs dict
     disabled = FieldProperty(bool, if_missing=False)
+    pending = FieldProperty(bool, if_missing=False)
 
     # Don't use these directly, use get/set_pref() instead
     preferences = FieldProperty(dict(

http://git-wip-us.apache.org/repos/asf/allura/blob/257c383d/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index add0a16..4a2b52b 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -537,7 +537,8 @@ class TestAuth(TestController):
                               username='aaa',
                               pw='12345678',
                               pw2='12345678',
-                              display_name='Test Me'))
+                              display_name='Test Me',
+                              email='test@example.com'))
         r = r.follow()
         assert 'User "aaa" registered' in unentity(r.body)
         r = self.app.post('/auth/save_new',
@@ -545,12 +546,15 @@ class TestAuth(TestController):
                               username='aaa',
                               pw='12345678',
                               pw2='12345678',
-                              display_name='Test Me'))
+                              display_name='Test Me',
+                              email='test@example.com'))
         assert 'That username is already taken. Please choose another.' in r
         r = self.app.get('/auth/logout')
         r = self.app.post('/auth/do_login',
                           params=dict(username='aaa', password='12345678'),
                           status=302)
+        user = M.User.query.get(username='aaa')
+        assert user.pending
 
     def test_create_account_disabled_header_link(self):
         with h.push_config(config, **{'auth.allow_user_registration': 'false'}):
@@ -582,7 +586,8 @@ class TestAuth(TestController):
             username='aaa',
             pw='12345678',
             pw2='12345678',
-            display_name='Test Me')).follow()
+            display_name='Test Me',
+            email='test@example.com')).follow()
         user = M.User.query.get(username='aaa')
         assert M.ProjectRole.query.find(
             dict(user_id=user._id, project_id=p._id)).count() == 0


[25/26] allura git commit: [#7794] ticket:686 Fix test back

Posted by je...@apache.org.
[#7794] ticket:686 Fix test back

Revert "[#7794] ticket:677 Fix test"

This reverts commit 86f76d5c405a008e4f453dde65579157387fab67.


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

Branch: refs/heads/ib/7794
Commit: 6dd838c7c01d5ec8e6dbae340fc6f72586cad2ef
Parents: 33d67a0
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 19 08:56:08 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 19 08:56:08 2014 +0000

----------------------------------------------------------------------
 ForgeDiscussion/forgediscussion/tests/functional/test_forum.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6dd838c7/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index cab95eb..34b71c9 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -485,7 +485,7 @@ class TestForum(TestController):
         r = self.app.get('/discussion/testforum/moderate/')
         post = FM.ForumPost.query.get(text='Post content')
         link = '<a href="%s">[%s]</a>' % (post.thread.url()
-                                          + '?limit=50#' + post.slug, post.shorthand_id())
+                                          + '?limit=25#' + post.slug, post.shorthand_id())
         assert link in r, link
 
     def test_thread(self):


[15/26] allura git commit: [#7704] ticket:683 Add migration to set user.pending to False

Posted by je...@apache.org.
[#7704] ticket:683 Add migration to set user.pending to False


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

Branch: refs/heads/ib/7794
Commit: 28cd9769726f330aad8578b0cb57d29a6e94a624
Parents: 4b6db4a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 12 11:28:40 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:05 2014 +0000

----------------------------------------------------------------------
 .../migrations/031-set-user-pending-to-false.py | 39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/28cd9769/scripts/migrations/031-set-user-pending-to-false.py
----------------------------------------------------------------------
diff --git a/scripts/migrations/031-set-user-pending-to-false.py b/scripts/migrations/031-set-user-pending-to-false.py
new file mode 100644
index 0000000..02d35d9
--- /dev/null
+++ b/scripts/migrations/031-set-user-pending-to-false.py
@@ -0,0 +1,39 @@
+#       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 ming.odm import ThreadLocalORMSession, state
+
+from allura.lib import utils
+from allura import model as M
+
+log = logging.getLogger(__name__)
+
+
+def main():
+    for chunk in utils.chunked_find(M.User):
+        for user in chunk:
+            print 'Processing {0}'.format(user.username)
+            user.pending = False
+            # Ming doesn't mark document for update, since pending is False
+            # by default, even if field is missing from mongo
+            state(user).status = state(user).dirty
+            ThreadLocalORMSession.flush_all()
+
+if __name__ == '__main__':
+    main()


[08/26] allura git commit: [#7704] ticket:662 Fixed user saving

Posted by je...@apache.org.
[#7704] ticket:662 Fixed user saving


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

Branch: refs/heads/ib/7794
Commit: 0eec07a73808f2932e428dc0346630b96571e6d7
Parents: 556e895
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Oct 8 14:58:57 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:03 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0eec07a7/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index c66b12e..b9e3d3b 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -264,7 +264,6 @@ class AuthController(BaseController):
             user = addr.claimed_by_user()
             if user.pending:
                 user.pending = False
-                user.m.save()
         else:
             flash('Unknown verification link', 'error')
 


[16/26] allura git commit: [#7704] ticket:683 Check for pending users in claimed_by_user

Posted by je...@apache.org.
[#7704] ticket:683 Check for pending users in claimed_by_user


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

Branch: refs/heads/ib/7794
Commit: 4b6db4a058d5a680914cbfe25f0e01fc013cd9c4
Parents: 026a381
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 12 11:05:04 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:05 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py |  5 ++---
 Allura/allura/lib/mail_util.py    |  4 ++--
 Allura/allura/model/auth.py       | 13 ++++++++++---
 3 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/4b6db4a0/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 489bacc..ef7935f 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -260,10 +260,9 @@ class AuthController(BaseController):
 
         if addr and not confirmed_by_other:
             addr.confirmed = True
+            user = addr.claimed_by_user(include_pending=True)
             flash('Email address confirmed')
-            h.auditlog_user('Email address verified: %s',  addr.email, user=addr.claimed_by_user())
-
-            user = addr.claimed_by_user()
+            h.auditlog_user('Email address verified: %s',  addr.email, user=user)
             if user.pending:
                 plugin.AuthenticationProvider.get(request).activate_user(user)
         else:

http://git-wip-us.apache.org/repos/asf/allura/blob/4b6db4a0/Allura/allura/lib/mail_util.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/mail_util.py b/Allura/allura/lib/mail_util.py
index 20fc411..5181889 100644
--- a/Allura/allura/lib/mail_util.py
+++ b/Allura/allura/lib/mail_util.py
@@ -161,13 +161,13 @@ def identify_sender(peer, email_address, headers, msg):
     addr = M.EmailAddress.query.get(
         email=M.EmailAddress.canonical(email_address), confirmed=True)
     if addr and addr.claimed_by_user_id:
-        return addr.claimed_by_user()
+        return addr.claimed_by_user() or M.User.anonymous()
     from_address = headers.get('From', '').strip()
     if not from_address:
         return M.User.anonymous()
     addr = M.EmailAddress.query.get(email=M.EmailAddress.canonical(from_address))
     if addr and addr.claimed_by_user_id:
-        return addr.claimed_by_user()
+        return addr.claimed_by_user() or M.User.anonymous()
     return M.User.anonymous()
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/4b6db4a0/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index ea07999..7928796 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -122,8 +122,13 @@ class EmailAddress(MappedClass):
     confirmed = FieldProperty(bool, if_missing=False)
     nonce = FieldProperty(str)
 
-    def claimed_by_user(self):
-        return User.query.get(_id=self.claimed_by_user_id, disabled=False)
+    def claimed_by_user(self, include_pending=False):
+        q = {'_id': self.claimed_by_user_id,
+             'disabled': False,
+             'pending': False}
+        if include_pending:
+            q.pop('pending', None)
+        return User.query.get(**q)
 
     @classmethod
     def create(cls, addr):
@@ -168,7 +173,9 @@ To verify the email address %s belongs to the user %s,
 please visit the following URL:
 
 %s
-''' % (self.email, self.claimed_by_user().username, g.url('/auth/verify_addr', a=self.nonce))
+''' % (self.email,
+       self.claimed_by_user(include_pending=True).username,
+       g.url('/auth/verify_addr', a=self.nonce))
         log.info('Verification email:\n%s', text)
         allura.tasks.mail_tasks.sendsimplemail.post(
             fromaddr=g.noreply,


[22/26] allura git commit: [#7794] ticket:677 Fix test

Posted by je...@apache.org.
[#7794] ticket:677 Fix test


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

Branch: refs/heads/ib/7794
Commit: 86f76d5c405a008e4f453dde65579157387fab67
Parents: 0c27260
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Nov 14 08:57:26 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 18 11:46:23 2014 +0000

----------------------------------------------------------------------
 ForgeDiscussion/forgediscussion/tests/functional/test_forum.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/86f76d5c/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 34b71c9..cab95eb 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -485,7 +485,7 @@ class TestForum(TestController):
         r = self.app.get('/discussion/testforum/moderate/')
         post = FM.ForumPost.query.get(text='Post content')
         link = '<a href="%s">[%s]</a>' % (post.thread.url()
-                                          + '?limit=25#' + post.slug, post.shorthand_id())
+                                          + '?limit=50#' + post.slug, post.shorthand_id())
         assert link in r, link
 
     def test_thread(self):


[26/26] allura git commit: [#7794] ticket:686 Fix tests failing due to new default limit

Posted by je...@apache.org.
[#7794] ticket:686 Fix tests failing due to new default limit


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

Branch: refs/heads/ib/7794
Commit: d62cd945ef46bab9be944c1dab4eba69328d019c
Parents: 6dd838c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 19 13:47:23 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Nov 19 13:47:23 2014 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_discussion.py            | 4 ++--
 Allura/allura/tests/test_globals.py                     | 6 +++---
 ForgeTracker/forgetracker/tests/functional/test_root.py | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d62cd945/Allura/allura/tests/model/test_discussion.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index f814fad..1768777 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -365,7 +365,7 @@ def test_post_url_paginated():
 
     # with default paging limit
     for _p in p:
-        url = t.url() + '?limit=50#' + _p.slug
+        url = t.url() + '?limit=25#' + _p.slug
         assert _p.url_paginated() == url, _p.url_paginated()
 
     # with user paging limit
@@ -387,7 +387,7 @@ def test_post_url_paginated_with_artifact():
     page = Page.upsert(title='Test Page')
     thread = page.discussion_thread
     comment = thread.post('Comment')
-    url = page.url() + '?limit=50#' + comment.slug
+    url = page.url() + '?limit=25#' + comment.slug
     assert_equals(comment.url_paginated(), url)
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/d62cd945/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 85eeb37..dd4e7e6 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -748,9 +748,9 @@ class TestHandlePaging(unittest.TestCase):
         self.assertEqual(c.user.get_pref('results_per_page'), None)
 
     def test_without_limit(self):
-        # default limit = 50
-        self.assertEqual(g.handle_paging(None, 0), (50, 0, 0))
-        self.assertEqual(g.handle_paging(None, 2), (50, 2, 100))
+        # default limit = 25
+        self.assertEqual(g.handle_paging(None, 0), (25, 0, 0))
+        self.assertEqual(g.handle_paging(None, 2), (25, 2, 50))
         # handle paging must not mess up user preferences
         self.assertEqual(c.user.get_pref('results_per_page'), None)
 

http://git-wip-us.apache.org/repos/asf/allura/blob/d62cd945/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index b882680..8506d3a 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1444,7 +1444,7 @@ class TestFunctionalController(TrackerTestController):
                       headers={'Referer': '/bugs/1/'.encode("utf-8")})
         r = self.app.get('/bugs/feed.rss')
         post = M.Post.query.find().first()
-        assert '/p/test/bugs/1/?limit=50#' + post.slug in r
+        assert '/p/test/bugs/1/?limit=25#' + post.slug in r
         r = self.app.get('/bugs/1/')
         post_link = str(
             r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
@@ -2042,7 +2042,7 @@ class TestFunctionalController(TrackerTestController):
             'app_config_id': ac_id,
             'ticket_num': 1}).first()
         post = ticket.discussion_thread.last_post
-        ticket_link = '/p/test2/bugs2/1/?limit=50#' + post.slug
+        ticket_link = '/p/test2/bugs2/1/?limit=25#' + post.slug
         msg = 'Ticket moved from /p/test/bugs/1/'
         assert_equal(post.text, msg)
         # auto comment content and link to it should be in a ticket's feed
@@ -2075,7 +2075,7 @@ class TestFunctionalController(TrackerTestController):
         assert_equal(comments_cnt, 2)  # moved auto comment + new comment
         post = ticket.discussion_thread.last_post
         # content and link to the ticket should be in a tracker's feed
-        ticket_link = '/p/test2/bugs2/1/?limit=50#' + post.slug
+        ticket_link = '/p/test2/bugs2/1/?limit=25#' + post.slug
         r = self.app.get('/p/test2/bugs2/feed')
         assert post_content in r, r
         assert ticket_link in r, r


[10/26] allura git commit: [#7704] ticket:662 Mention verification email in flash message

Posted by je...@apache.org.
[#7704] ticket:662 Mention verification email in flash message


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

Branch: refs/heads/ib/7794
Commit: 50eeec2c1e3a477221d92fa7b6cfbb63e18779fa
Parents: d99f238
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:47:43 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/50eeec2c/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 875ebeb..35d8207 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -233,7 +233,9 @@ class AuthController(BaseController):
         if require_email:
             em = user.claim_address(email)
             em.send_verification_link()
-        flash('User "%s" registered' % username)
+            flash('User "%s" registered. Verification link was sent to your email.' % username)
+        else:
+            flash('User "%s" registered' % username)
         redirect('/')
 
     @expose()


[11/26] allura git commit: [#7704] ticket:662 Don't try to log in if user isn't active after registration

Posted by je...@apache.org.
[#7704] ticket:662 Don't try to log in if user isn't active after registration


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

Branch: refs/heads/ib/7794
Commit: fce5dfd08325dc15b8a6758c7187313656ebbdb6
Parents: 50eeec2
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:49:16 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/fce5dfd0/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 35d8207..489bacc 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -229,12 +229,12 @@ class AuthController(BaseController):
                  display_name=display_name,
                  password=pw,
                  pending=require_email))
-        plugin.AuthenticationProvider.get(request).login(user)
         if require_email:
             em = user.claim_address(email)
             em.send_verification_link()
             flash('User "%s" registered. Verification link was sent to your email.' % username)
         else:
+            plugin.AuthenticationProvider.get(request).login(user)
             flash('User "%s" registered' % username)
         redirect('/')
 


[13/26] allura git commit: [#7704] ticket:662 Claim email only if option is set

Posted by je...@apache.org.
[#7704] ticket:662 Claim email only if option is set


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

Branch: refs/heads/ib/7794
Commit: d99f238f6759d65c5ef30788fa92084644b121d5
Parents: 3095f42
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Oct 15 11:31:40 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d99f238f/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 4076b14..875ebeb 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -223,13 +223,14 @@ class AuthController(BaseController):
     def save_new(self, display_name=None, username=None, pw=None, email=None, **kw):
         if not asbool(config.get('auth.allow_user_registration', True)):
             raise wexc.HTTPNotFound()
+        require_email = asbool(config.get('auth.require_email_addr', False))
         user = M.User.register(
             dict(username=username,
                  display_name=display_name,
                  password=pw,
-                 pending=asbool(config.get('auth.require_email_addr', False))))
+                 pending=require_email))
         plugin.AuthenticationProvider.get(request).login(user)
-        if email is not None:
+        if require_email:
             em = user.claim_address(email)
             em.send_verification_link()
         flash('User "%s" registered' % username)


[07/26] allura git commit: [#7704] ticket:662 Moved user activation to auth plugin, extended tests

Posted by je...@apache.org.
[#7704] ticket:662 Moved user activation to auth plugin, extended tests


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

Branch: refs/heads/ib/7794
Commit: fc4623eb5dfc67e3da20a515d0ef313244ccc49f
Parents: 0eec07a
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Thu Oct 9 15:42:33 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:03 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py           | 11 ++--
 Allura/allura/lib/plugin.py                 | 12 ++++
 Allura/allura/lib/widgets/forms.py          | 13 ++--
 Allura/allura/tests/functional/test_auth.py | 84 ++++++++++++++++++------
 4 files changed, 89 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/fc4623eb/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index b9e3d3b..4076b14 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -227,12 +227,11 @@ class AuthController(BaseController):
             dict(username=username,
                  display_name=display_name,
                  password=pw,
-                 email_addresses=[email],
-                 pending=True))
+                 pending=asbool(config.get('auth.require_email_addr', False))))
         plugin.AuthenticationProvider.get(request).login(user)
-        em = M.EmailAddress.create(email)
-        em.claimed_by_user_id = user._id
-        em.send_verification_link()
+        if email is not None:
+            em = user.claim_address(email)
+            em.send_verification_link()
         flash('User "%s" registered' % username)
         redirect('/')
 
@@ -263,7 +262,7 @@ class AuthController(BaseController):
 
             user = addr.claimed_by_user()
             if user.pending:
-                user.pending = False
+                plugin.AuthenticationProvider.get(request).activate_user(user)
         else:
             flash('Unknown verification link', 'error')
 

http://git-wip-us.apache.org/repos/asf/allura/blob/fc4623eb/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 82284f2..6389360 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -189,6 +189,10 @@ class AuthenticationProvider(object):
         '''Enable user account'''
         raise NotImplementedError, 'enable_user'
 
+    def activate_user(self, user):
+        '''Activate user after registration'''
+        raise NotImplementedError, 'activate_user'
+
     def by_username(self, username):
         '''
         Find a user by username.
@@ -350,6 +354,11 @@ class LocalAuthenticationProvider(AuthenticationProvider):
         session(user).flush(user)
         h.auditlog_user(u'Account enabled', user=user)
 
+    def activate_user(self, user):
+        user.pending = False
+        session(user).flush(user)
+        h.auditlog_user('Account activated', user=user)
+
     def validate_password(self, user, password):
         return self._validate_password(user, password)
 
@@ -601,6 +610,9 @@ class LdapAuthenticationProvider(AuthenticationProvider):
     def enable_user(self, user):
         return LocalAuthenticationProvider(None).enable_user(user)
 
+    def activate_user(self, user):
+        return LocalAuthenticationProvider(None).activate_user(user)
+
     def get_last_password_updated(self, user):
         return LocalAuthenticationProvider(None).get_last_password_updated(user)
 

http://git-wip-us.apache.org/repos/asf/allura/blob/fc4623eb/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 3d243e2..6f23e40 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -27,6 +27,7 @@ import ew.jinja2_ew as ew
 from pytz import common_timezones, country_timezones, country_names
 from paste.deploy.converters import aslist, asint, asbool
 import tg
+from tg import config
 
 from allura.lib import validators as V
 from allura.lib import helpers as h
@@ -749,16 +750,19 @@ class RegistrationForm(ForgeForm):
             'Usernames must include only letters, numbers, and dashes.'
             ' They must also start with a letter and be at least 3 characters'
             ' long.')
-        return [
+        fields = [
             ew.TextField(
                 name='display_name',
                 label='Displayed Name',
                 validator=fev.UnicodeString(not_empty=True)),
             username,
-            ew.TextField(
+        ]
+        if asbool(config.get('auth.require_email_addr', False)):
+            fields.append(ew.TextField(
                 name='email',
                 label='Your e-mail',
-                validator=fev.Email()),
+                validator=fev.Email(not_empty=True)))
+        fields += [
             ew.PasswordField(
                 name='pw',
                 label='New Password',
@@ -766,11 +770,12 @@ class RegistrationForm(ForgeForm):
                     not_empty=True,
                     min=asint(tg.config.get('auth.min_password_len', 6)),
                     max=asint(tg.config.get('auth.max_password_len', 30)))),
-             ew.PasswordField(
+            ew.PasswordField(
                 name='pw2',
                 label='New Password (again)',
                 validator=fev.UnicodeString(not_empty=True)),
         ]
+        return fields
 
     @ew_core.core.validator
     def to_python(self, value, state):

http://git-wip-us.apache.org/repos/asf/allura/blob/fc4623eb/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 3a50b7c..2206f37 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -532,31 +532,72 @@ class TestAuth(TestController):
         r = self.app.post('/auth/save_new',
                           params=dict(username='aaa', pw='123'))
         assert 'Enter a value 6 characters long or more' in r
-        r = self.app.post('/auth/save_new',
-                          params=dict(
-                              username='aaa',
-                              pw='12345678',
-                              pw2='12345678',
-                              display_name='Test Me',
-                              email='test@example.com'))
+        r = self.app.post(
+            '/auth/save_new',
+            params=dict(
+                username='aaa',
+                pw='12345678',
+                pw2='12345678',
+                display_name='Test Me'))
         r = r.follow()
         assert 'User "aaa" registered' in unentity(r.body)
-        r = self.app.post('/auth/save_new',
-                          params=dict(
-                              username='aaa',
-                              pw='12345678',
-                              pw2='12345678',
-                              display_name='Test Me',
-                              email='test@example.com'))
+        r = self.app.post(
+            '/auth/save_new',
+            params=dict(
+                username='aaa',
+                pw='12345678',
+                pw2='12345678',
+                display_name='Test Me'))
         assert 'That username is already taken. Please choose another.' in r
         r = self.app.get('/auth/logout')
-        user = M.User.query.get(username='aaa')
-        assert user.pending
-        user.pending = False
-        session(user).flush(user)
-        r = self.app.post('/auth/do_login',
-                          params=dict(username='aaa', password='12345678'),
-                          status=302)
+        r = self.app.post(
+            '/auth/do_login',
+            params=dict(username='aaa', password='12345678'),
+            status=302)
+
+    def test_create_account_require_email(self):
+        with h.push_config(config, **{'auth.require_email_addr': 'false'}):
+            self.app.post(
+                '/auth/save_new',
+                params=dict(
+                    username='aaa',
+                    pw='12345678',
+                    pw2='12345678',
+                    display_name='Test Me',
+                    email='test@example.com'))
+            user = M.User.query.get(username='aaa')
+            assert not user.pending
+        with h.push_config(config, **{'auth.require_email_addr': 'true'}):
+            self.app.post(
+                '/auth/save_new',
+                params=dict(
+                    username='bbb',
+                    pw='12345678',
+                    pw2='12345678',
+                    display_name='Test Me',
+                    email='test@example.com'))
+            user = M.User.query.get(username='bbb')
+            assert user.pending
+
+    def test_verify_email(self):
+        with h.push_config(config, **{'auth.require_email_addr': 'true'}):
+            r = self.app.post(
+                '/auth/save_new',
+                params=dict(
+                    username='aaa',
+                    pw='12345678',
+                    pw2='12345678',
+                    display_name='Test Me',
+                    email='test@example.com'))
+            r = r.follow()
+            user = M.User.query.get(username='aaa')
+            em = M.EmailAddress.query.get(email='test@example.com')
+            assert user._id == em.claimed_by_user_id
+            r = self.app.get('/auth/verify_addr', params=dict(a=em.nonce))
+            user = M.User.query.get(username='aaa')
+            em = M.EmailAddress.query.get(email='test@example.com')
+            assert not user.pending
+            assert em.confirmed
 
     def test_create_account_disabled_header_link(self):
         with h.push_config(config, **{'auth.allow_user_registration': 'false'}):
@@ -595,6 +636,7 @@ class TestAuth(TestController):
         session(user).flush(user)
         assert M.ProjectRole.query.find(
             dict(user_id=user._id, project_id=p._id)).count() == 0
+
         self.app.get('/p/test/admin/permissions',
                      extra_environ=dict(username='aaa'), status=403)
         assert M.ProjectRole.query.find(


[19/26] allura git commit: [#7794] ticket:677 Remove hard limit on page size where it makes sense

Posted by je...@apache.org.
[#7794] ticket:677 Remove hard limit on page size where it makes sense


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

Branch: refs/heads/ib/7794
Commit: 3275593c72eb3e73b72b45155188d3fdf3f25cf2
Parents: 015416b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Nov 14 08:13:15 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 18 11:46:22 2014 +0000

----------------------------------------------------------------------
 ForgeDiscussion/forgediscussion/controllers/forum.py |  4 ++--
 ForgeDiscussion/forgediscussion/controllers/root.py  | 12 ++++++------
 ForgeShortUrl/forgeshorturl/main.py                  |  4 ++--
 ForgeWiki/forgewiki/wiki_main.py                     |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/3275593c/ForgeDiscussion/forgediscussion/controllers/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/forum.py b/ForgeDiscussion/forgediscussion/controllers/forum.py
index c83adaf..67dbea3 100644
--- a/ForgeDiscussion/forgediscussion/controllers/forum.py
+++ b/ForgeDiscussion/forgediscussion/controllers/forum.py
@@ -99,8 +99,8 @@ class ForumController(DiscussionController):
 
     @expose('jinja:forgediscussion:templates/index.html')
     @validate(dict(page=validators.Int(if_empty=0, if_invalid=0),
-                   limit=validators.Int(if_empty=25, if_invalid=25)))
-    def index(self, threads=None, limit=25, page=0, count=0, **kw):
+                   limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, threads=None, limit=None, page=0, count=0, **kw):
         if self.discussion.deleted:
             redirect(self.discussion.url() + 'deleted')
         limit, page, start = g.handle_paging(limit, page)

http://git-wip-us.apache.org/repos/asf/allura/blob/3275593c/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 9256662..cf1116e 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -307,8 +307,8 @@ class RootRestController(BaseController):
         return ForumRestController(unquote(forum)), remainder
 
     @expose('json:')
-    def index(self, limit=100, page=0, **kw):
-        limit, page, start = g.handle_paging(int(limit), int(page))
+    def index(self, limit=None, page=0, **kw):
+        limit, page, start = g.handle_paging(limit, int(page))
         forums = model.Forum.query.find(dict(
             app_config_id=c.app.config._id,
             parent_id=None, deleted=False)
@@ -377,8 +377,8 @@ class ForumRestController(BaseController):
         require_access(self.forum, 'read')
 
     @expose('json:')
-    def index(self, limit=100, page=0, **kw):
-        limit, page, start = g.handle_paging(int(limit), int(page))
+    def index(self, limit=None, page=0, **kw):
+        limit, page, start = g.handle_paging(limit, int(page))
         topics = model.Forum.thread_class().query.find(
             dict(discussion_id=self.forum._id))
         topics = topics.sort([('flags', pymongo.DESCENDING),
@@ -423,8 +423,8 @@ class ForumTopicRestController(BaseController):
         require_access(self.forum, 'read')
 
     @expose('json:')
-    def index(self, limit=100, page=0, **kw):
-        limit, page, start = g.handle_paging(int(limit), int(page))
+    def index(self, limit=None, page=0, **kw):
+        limit, page, start = g.handle_paging(limit, int(page))
         json_data = {}
         json_data['topic'] = self.topic.__json__(limit=limit, page=page)
         json_data['count'] = self.topic.query_posts(status='ok').count()

http://git-wip-us.apache.org/repos/asf/allura/blob/3275593c/ForgeShortUrl/forgeshorturl/main.py
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/main.py b/ForgeShortUrl/forgeshorturl/main.py
index 377fa62..f4ab4ed 100644
--- a/ForgeShortUrl/forgeshorturl/main.py
+++ b/ForgeShortUrl/forgeshorturl/main.py
@@ -132,8 +132,8 @@ class RootController(BaseController):
 
     @expose('jinja:forgeshorturl:templates/index.html')
     @validate(dict(page=validators.Int(if_empty=0, if_invalid=0),
-                   limit=validators.Int(if_empty=100, if_invalid=100)))
-    def index(self, page=0, limit=100, **kw):
+                   limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, page=0, limit=None, **kw):
         c.page_list = W.page_list
         c.page_size = W.page_size
         limit, pagenum, start = g.handle_paging(limit, page, default=100)

http://git-wip-us.apache.org/repos/asf/allura/blob/3275593c/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index e32a741..8539409 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -409,7 +409,7 @@ class RootController(BaseController, DispatchIndex, FeedController):
     @expose('jinja:forgewiki:templates/wiki/browse_tags.html')
     @validate(dict(sort=validators.UnicodeString(if_empty='alpha'),
                    page=validators.Int(if_empty=0, if_invalid=0),
-                   limit=validators.Int(if_empty=25, if_invalid=25)))
+                   limit=validators.Int(if_empty=None, if_invalid=None)))
     def browse_tags(self, sort='alpha', page=0, limit=None, **kw):
         'list of all labels in the wiki'
         c.page_list = W.page_list


[09/26] allura git commit: [#7704] ticket:662 Fixed tests

Posted by je...@apache.org.
[#7704] ticket:662 Fixed tests


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

Branch: refs/heads/ib/7794
Commit: 556e8957479742ef7749d547d50e1731813fd9c9
Parents: 221bded
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Oct 8 14:49:24 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:03 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py           | 7 ++++---
 Allura/allura/tests/functional/test_auth.py | 8 ++++++--
 2 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/556e8957/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index cec2b28..c66b12e 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -261,9 +261,10 @@ class AuthController(BaseController):
             flash('Email address confirmed')
             h.auditlog_user('Email address verified: %s',  addr.email, user=addr.claimed_by_user())
 
-            if addr.claimed_by_user.pending:
-                addr.claimed_by_user.pending = False
-                addr.claimed_by_user.m.save()
+            user = addr.claimed_by_user()
+            if user.pending:
+                user.pending = False
+                user.m.save()
         else:
             flash('Unknown verification link', 'error')
 

http://git-wip-us.apache.org/repos/asf/allura/blob/556e8957/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 4a2b52b..3a50b7c 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -550,11 +550,13 @@ class TestAuth(TestController):
                               email='test@example.com'))
         assert 'That username is already taken. Please choose another.' in r
         r = self.app.get('/auth/logout')
+        user = M.User.query.get(username='aaa')
+        assert user.pending
+        user.pending = False
+        session(user).flush(user)
         r = self.app.post('/auth/do_login',
                           params=dict(username='aaa', password='12345678'),
                           status=302)
-        user = M.User.query.get(username='aaa')
-        assert user.pending
 
     def test_create_account_disabled_header_link(self):
         with h.push_config(config, **{'auth.allow_user_registration': 'false'}):
@@ -589,6 +591,8 @@ class TestAuth(TestController):
             display_name='Test Me',
             email='test@example.com')).follow()
         user = M.User.query.get(username='aaa')
+        user.pending = False
+        session(user).flush(user)
         assert M.ProjectRole.query.find(
             dict(user_id=user._id, project_id=p._id)).count() == 0
         self.app.get('/p/test/admin/permissions',


[05/26] allura git commit: [#7704] ticket:662 Clear pending status on confirming an email address

Posted by je...@apache.org.
[#7704] ticket:662 Clear pending status on confirming an email address


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

Branch: refs/heads/ib/7794
Commit: a175f3e2aff0d3dee8e8a823eef838078a2a7e16
Parents: 257c383
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 20:45:43 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:02 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a175f3e2/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 5d966a1..cec2b28 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -259,7 +259,11 @@ class AuthController(BaseController):
         if addr and not confirmed_by_other:
             addr.confirmed = True
             flash('Email address confirmed')
-            h.auditlog_user('Email address verified: %s', addr.email, user=addr.claimed_by_user())
+            h.auditlog_user('Email address verified: %s',  addr.email, user=addr.claimed_by_user())
+
+            if addr.claimed_by_user.pending:
+                addr.claimed_by_user.pending = False
+                addr.claimed_by_user.m.save()
         else:
             flash('Unknown verification link', 'error')
 


[06/26] allura git commit: [#7704] ticket:662 Added pending field to index

Posted by je...@apache.org.
[#7704] ticket:662 Added pending field to index


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

Branch: refs/heads/ib/7794
Commit: 8f034856893361f167e47081142102de6ce7bf14
Parents: fc4623e
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Oct 10 00:53:26 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:03 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/8f034856/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index ee2793b..96a9795 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -315,6 +315,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
             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,
+            pending_b=self.pending,
             results_per_page_i=self.get_pref('results_per_page'),
             email_address_s=self.get_pref('email_address'),
             email_format_s=self.get_pref('email_format'),


[17/26] allura git commit: [#7794] ticket:677 Add tests for g.handle_paging

Posted by je...@apache.org.
[#7794] ticket:677 Add tests for g.handle_paging


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

Branch: refs/heads/ib/7794
Commit: e2bd828d67536345c1b1d8fb89d6525b1a07fe0d
Parents: 28cd976
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Nov 10 13:26:31 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 18 11:46:22 2014 +0000

----------------------------------------------------------------------
 Allura/allura/tests/test_globals.py | 50 +++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e2bd828d/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 5dc0e43..85eeb37 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -23,7 +23,7 @@ import os
 import allura
 import unittest
 import hashlib
-from mock import patch
+from mock import patch, Mock
 
 from bson import ObjectId
 from nose.tools import with_setup, assert_equal, assert_in, assert_not_in
@@ -726,3 +726,51 @@ class TestCachedMarkdown(unittest.TestCase):
         self.assertIsNone(self.post.text_cache.md5)
         self.assertIsNone(self.post.text_cache.html)
         self.assertIsNone(self.post.text_cache.render_time)
+
+
+
+class TestHandlePaging(unittest.TestCase):
+
+    def setUp(self):
+        prefs = {}
+        c.user = Mock()
+        def get_pref(name):
+            return prefs.get(name)
+        def set_pref(name, value):
+            prefs[name] = value
+        c.user.get_pref = get_pref
+        c.user.set_pref = set_pref
+
+    def test_with_limit(self):
+        self.assertEqual(g.handle_paging(10, 0), (10, 0, 0))
+        self.assertEqual(g.handle_paging(10, 2), (10, 2, 20))
+        # handle paging must not mess up user preferences
+        self.assertEqual(c.user.get_pref('results_per_page'), None)
+
+    def test_without_limit(self):
+        # default limit = 50
+        self.assertEqual(g.handle_paging(None, 0), (50, 0, 0))
+        self.assertEqual(g.handle_paging(None, 2), (50, 2, 100))
+        # handle paging must not mess up user preferences
+        self.assertEqual(c.user.get_pref('results_per_page'), None)
+
+        # user has page size preference
+        c.user.set_pref('results_per_page', 100)
+        self.assertEqual(g.handle_paging(None, 0), (100, 0, 0))
+        self.assertEqual(g.handle_paging(None, 2), (100, 2, 200))
+        # handle paging must not mess up user preferences
+        self.assertEqual(c.user.get_pref('results_per_page'), 100)
+
+    def test_without_limit_with_default(self):
+        # default limit is not used when explicitly provided
+        self.assertEqual(g.handle_paging(None, 0, 30), (30, 0, 0))
+        self.assertEqual(g.handle_paging(None, 2, 30), (30, 2, 60))
+        # handle paging must not mess up user preferences
+        self.assertEqual(c.user.get_pref('results_per_page'), None)
+
+        # user has page size preference, which is not affected by default
+        c.user.set_pref('results_per_page', 25)
+        self.assertEqual(g.handle_paging(None, 0, 30), (25, 0, 0))
+        self.assertEqual(g.handle_paging(None, 2, 30), (25, 2, 50))
+        # handle paging must not mess up user preferences
+        self.assertEqual(c.user.get_pref('results_per_page'), 25)


[24/26] allura git commit: [#7794] ticket:686 Set default page size to 25

Posted by je...@apache.org.
[#7794] ticket:686 Set default page size to 25


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

Branch: refs/heads/ib/7794
Commit: 33d67a0514867f1a69fc91bc690748ed168409db
Parents: 8811b27
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Nov 18 11:57:02 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 18 11:57:02 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/33d67a05/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 0564f75..8435f0f 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -380,13 +380,13 @@ class Globals(object):
     def credentials(self):
         return Credentials.get()
 
-    def handle_paging(self, limit, page, default=50):
+    def handle_paging(self, limit, page, default=25):
         limit = self.manage_paging_preference(limit, default)
         page = max(int(page), 0)
         start = page * int(limit)
         return (limit, page, start)
 
-    def manage_paging_preference(self, limit, default=50):
+    def manage_paging_preference(self, limit, default=25):
         if not limit:
             if c.user in (None, M.User.anonymous()):
                 limit = default


[21/26] allura git commit: [#7794] ticket:677 Always cast limit to int

Posted by je...@apache.org.
[#7794] ticket:677 Always cast limit to int


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

Branch: refs/heads/ib/7794
Commit: 0c27260537aca2628f900eb063dc4f6284969651
Parents: 053903f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Nov 14 08:55:49 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 18 11:46:23 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0c272605/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index ac8bcdb..0564f75 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -392,7 +392,7 @@ class Globals(object):
                 limit = default
             else:
                 limit = c.user.get_pref('results_per_page') or default
-        return limit
+        return int(limit)
 
     def document_class(self, neighborhood):
         classes = ''


[12/26] allura git commit: [#7704] ticket:683 Update log message

Posted by je...@apache.org.
[#7704] ticket:683 Update log message


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

Branch: refs/heads/ib/7794
Commit: 026a3819dd17ad6be42f6febb1ba7e80e74c9ff6
Parents: fce5dfd
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Nov 12 10:29:29 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/026a3819/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 6389360..c0dbf51 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -569,7 +569,7 @@ class LdapAuthenticationProvider(AuthenticationProvider):
                 log.debug('LdapAuth: no user {} found in local mongo'.format(username))
                 raise exc.HTTPUnauthorized()
         elif user.disabled or user.pending:
-            log.debug('LdapAuth: user {} is disabled in Allura'.format(username))
+            log.debug('LdapAuth: user {} is disabled or pending in Allura'.format(username))
             raise exc.HTTPUnauthorized()
         return user
 


[20/26] allura git commit: [#7794] ticket:677 Add handle_paging calls where only sanitizer is used

Posted by je...@apache.org.
[#7794] ticket:677 Add handle_paging calls where only sanitizer is used


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

Branch: refs/heads/ib/7794
Commit: 053903f0eee81210d771e87c25d5fb0cadba1b73
Parents: 3275593
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Nov 14 08:26:51 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 18 11:46:23 2014 +0000

----------------------------------------------------------------------
 ForgeBlog/forgeblog/main.py               | 11 +++++++----
 ForgeTracker/forgetracker/tracker_main.py |  5 +++--
 ForgeWiki/forgewiki/wiki_main.py          |  7 ++++---
 3 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/053903f0/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 9e70769..1e3f604 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -25,6 +25,7 @@ import pymongo
 from tg import config, expose, validate, redirect, flash, jsonify
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from pylons import tmpl_context as c
+from pylons import app_globals as g
 from pylons import request
 from paste.deploy.converters import asbool
 import formencode
@@ -213,13 +214,14 @@ class RootController(BaseController, FeedController):
     @expose('jinja:forgeblog:templates/blog/index.html')
     @with_trailing_slash
     @validate(dict(page=validators.Int(if_empty=0, if_invalid=0),
-                   limit=validators.Int(if_empty=25, if_invalid=25)))
-    def index(self, page=0, limit=10, **kw):
+                   limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, page=0, limit=None, **kw):
         query_filter = dict(app_config_id=c.app.config._id)
         if not has_access(c.app, 'write')():
             query_filter['state'] = 'published'
         q = BM.BlogPost.query.find(query_filter)
         post_count = q.count()
+        limit, page, _ = g.handle_paging(limit, page)
         limit, page = h.paging_sanitizer(limit, page, post_count)
         posts = q.sort('timestamp', pymongo.DESCENDING) \
                  .skip(page * limit).limit(limit)
@@ -295,14 +297,15 @@ class PostController(BaseController, FeedController):
     @expose('jinja:forgeblog:templates/blog/post.html')
     @with_trailing_slash
     @validate(dict(page=validators.Int(if_empty=0, if_invalid=0),
-                   limit=validators.Int(if_empty=25, if_invalid=25)))
-    def index(self, page=0, limit=25, **kw):
+                   limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, page=0, limit=None, **kw):
         if self.post.state == 'draft':
             require_access(self.post, 'write')
         c.form = W.view_post_form
         c.subscribe_form = W.subscribe_form
         c.thread = W.thread
         post_count = self.post.discussion_thread.post_count
+        limit, page, _ = g.handle_paging(limit, page)
         limit, page = h.paging_sanitizer(limit, page, post_count)
         version = kw.pop('version', None)
         post = self._get_version(version)

http://git-wip-us.apache.org/repos/asf/allura/blob/053903f0/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index fd8917e..9cc3596 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1287,8 +1287,8 @@ class TicketController(BaseController, FeedController):
     @expose('jinja:forgetracker:templates/tracker/ticket.html')
     @validate(dict(
         page=validators.Int(if_empty=0, if_invalid=0),
-        limit=validators.Int(if_empty=10, if_invalid=10)))
-    def index(self, page=0, limit=10, deleted=False, **kw):
+        limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, page=0, limit=None, deleted=False, **kw):
         ticket_visible = self.ticket and not self.ticket.deleted
         if ticket_visible or has_access(self.ticket, 'delete'):
             c.ticket_form = W.ticket_form
@@ -1303,6 +1303,7 @@ class TicketController(BaseController, FeedController):
             else:
                 subscribed = M.Mailbox.subscribed(artifact=self.ticket)
             post_count = self.ticket.discussion_thread.post_count
+            limit, page, _ = g.handle_paging(limit, page)
             limit, page = h.paging_sanitizer(limit, page, post_count)
             voting_enabled = self.ticket.app.config.options.get('EnableVoting')
             return dict(ticket=self.ticket, globals=c.app.globals,

http://git-wip-us.apache.org/repos/asf/allura/blob/053903f0/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 8539409..3341377 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -504,8 +504,8 @@ class PageController(BaseController, FeedController):
     @expose('jinja:forgewiki:templates/wiki/page_view.html')
     @validate(dict(version=validators.Int(if_empty=None, if_invalid=None),
                    page=validators.Int(if_empty=0, if_invalid=0),
-                   limit=validators.Int(if_empty=25, if_invalid=25)))
-    def index(self, version=None, page=0, limit=25, **kw):
+                   limit=validators.Int(if_empty=None, if_invalid=None)))
+    def index(self, version=None, page=0, limit=None, **kw):
         if not self.page:
             redirect(c.app.url + h.urlquote(self.title) + '/edit')
         c.confirmation = W.confirmation
@@ -513,7 +513,8 @@ class PageController(BaseController, FeedController):
         c.attachment_list = W.attachment_list
         c.subscribe_form = W.page_subscribe_form
         post_count = self.page.discussion_thread.post_count
-        limit, pagenum = h.paging_sanitizer(limit, page, post_count)
+        limit, pagenum, _ = g.handle_paging(limit, page)
+        limit, pagenum = h.paging_sanitizer(limit, pagenum, post_count)
         page = self.get_version(version)
         if page is None:
             if version:


[18/26] allura git commit: [#7794] ticket:677 Always use user prefs for page size

Posted by je...@apache.org.
[#7794] ticket:677 Always use user prefs for page size


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

Branch: refs/heads/ib/7794
Commit: 015416ba6b9335f1d3232520d20499a1dac3e44d
Parents: e2bd828
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Nov 14 07:45:49 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Tue Nov 18 11:46:22 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/app_globals.py | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/015416ba/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 2d5136e..ac8bcdb 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -387,19 +387,9 @@ class Globals(object):
         return (limit, page, start)
 
     def manage_paging_preference(self, limit, default=50):
-        if limit:
+        if not limit:
             if c.user in (None, M.User.anonymous()):
-                session['results_per_page'] = int(limit)
-                session.save()
-            else:
-                c.user.set_pref('results_per_page', int(limit))
-        else:
-            if c.user in (None, M.User.anonymous()):
-                try:
-                    limit = session['results_per_page']
-                # TypeError if no session registered for thread
-                except (KeyError, TypeError):
-                    limit = default
+                limit = default
             else:
                 limit = c.user.get_pref('results_per_page') or default
         return limit


[14/26] allura git commit: [#7704] ticket:662 Check for pending status in User.private_project

Posted by je...@apache.org.
[#7704] ticket:662 Check for pending status in User.private_project


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

Branch: refs/heads/ib/7794
Commit: 3095f426816cbe59d1a7c2d6a844be1c7a0986ca
Parents: 8f03485
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Oct 10 00:54:43 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:04 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/3095f426/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 96a9795..ea07999 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -669,7 +669,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         '''
         Returns the personal user-project for the user
         '''
-        if self.disabled:
+        if self.disabled or self.pending:
             return None
 
         from allura import model as M


[04/26] allura git commit: [#7704] ticket:662 Added checks for pending status

Posted by je...@apache.org.
[#7704] ticket:662 Added checks for pending status


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

Branch: refs/heads/ib/7794
Commit: 221bded2ed6c33142d5501adc44ddd62ccc81674
Parents: a175f3e
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Oct 7 20:58:28 2014 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Nov 17 19:18:02 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py |  5 +++--
 Allura/allura/lib/plugin.py          | 10 +++++-----
 Allura/allura/model/notification.py  |  4 ++--
 Allura/allura/model/project.py       |  2 +-
 Allura/allura/tasks/mail_tasks.py    |  8 ++++----
 5 files changed, 15 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 2267dcf..8f2b2ef 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -101,7 +101,7 @@ class NeighborhoodController(object):
                 shortname=self.prefix + pname, neighborhood_id=self.neighborhood._id)
         if project is None and self.prefix == 'u/':
             # create user-project if it is missing
-            user = M.User.query.get(username=pname, disabled=False)
+            user = M.User.query.get(username=pname, disabled=False, pending=False)
             if user:
                 project = self.neighborhood.register_project(
                     plugin.AuthenticationProvider.get(
@@ -115,7 +115,7 @@ class NeighborhoodController(object):
         if project and self.prefix == 'u/':
             # make sure user-projects are associated with an enabled user
             user = project.user_project_of
-            if not user or user.disabled:
+            if not user or user.disabled or user.pending:
                 raise exc.HTTPNotFound
         if project.database_configured == False:
             if remainder == ('user_icon',):
@@ -455,6 +455,7 @@ class ProjectController(FeedController):
             '_id': {'$in': named_roles.userids_that_reach},
             'display_name': re.compile(r'(?i)%s' % re.escape(term)),
             'disabled': False,
+            'pending': False,
         }).sort('username').limit(10).all()
         return dict(
             users=[

http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index a2a57b1..82284f2 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -103,7 +103,7 @@ class AuthenticationProvider(object):
 
         if user is None:
             return M.User.anonymous()
-        if user.disabled:
+        if user.disabled or user.pending:
             self.logout()
             return M.User.anonymous()
 
@@ -370,7 +370,7 @@ class LocalAuthenticationProvider(AuthenticationProvider):
         un = un.replace(r'\_', '[-_]')
         un = un.replace(r'\-', '[-_]')
         rex = re.compile('^' + un + '$')
-        return M.User.query.get(username=rex, disabled=False)
+        return M.User.query.get(username=rex, disabled=False, pending=False)
 
     def set_password(self, user, old_password, new_password):
         if old_password is not None and not self.validate_password(user, old_password):
@@ -393,7 +393,7 @@ class LocalAuthenticationProvider(AuthenticationProvider):
 
     def user_by_project_shortname(self, shortname):
         from allura import model as M
-        return M.User.query.get(username=shortname, disabled=False)
+        return M.User.query.get(username=shortname, disabled=False, pending=False)
 
     def update_notifications(self, user):
         return ''
@@ -522,7 +522,7 @@ class LdapAuthenticationProvider(AuthenticationProvider):
 
     def by_username(self, username):
         from allura import model as M
-        return M.User.query.get(username=username, disabled=False)
+        return M.User.query.get(username=username, disabled=False, pending=False)
 
     def set_password(self, user, old_password, new_password):
         dn = ldap_user_dn(user.username)
@@ -559,7 +559,7 @@ class LdapAuthenticationProvider(AuthenticationProvider):
             else:
                 log.debug('LdapAuth: no user {} found in local mongo'.format(username))
                 raise exc.HTTPUnauthorized()
-        elif user.disabled:
+        elif user.disabled or user.pending:
             log.debug('LdapAuth: user {} is disabled in Allura'.format(username))
             raise exc.HTTPUnauthorized()
         return user

http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index ad27f5f..8c82890 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -277,7 +277,7 @@ class Notification(MappedClass):
             text=(self.text or '') + self.footer(toaddr))
 
     def send_direct(self, user_id):
-        user = User.query.get(_id=ObjectId(user_id), disabled=False)
+        user = User.query.get(_id=ObjectId(user_id), disabled=False, pending=False)
         artifact = self.ref.artifact
         log.debug('Sending direct notification %s to user %s',
                   self._id, user_id)
@@ -313,7 +313,7 @@ class Notification(MappedClass):
                     reply_to_address=None):
         if not notifications:
             return
-        user = User.query.get(_id=ObjectId(user_id), disabled=False)
+        user = User.query.get(_id=ObjectId(user_id), disabled=False, pending=False)
         if not user:
             log.debug("Skipping notification - enabled user %s not found " %
                       user_id)

http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index f164b4e..42e8e8d 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -857,7 +857,7 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
             g.credentials.project_roles(project_id=self.root_project._id).named)
         uids = [
             uid for uid in named_roles.userids_that_reach if uid is not None]
-        return list(User.query.find({'_id': {'$in': uids}, 'disabled': False}))
+        return list(User.query.find({'_id': {'$in': uids}, 'disabled': False, 'pending': False}))
 
     def users_with_role(self, *role_names):
         """Return all users in this project that have at least one of the roles

http://git-wip-us.apache.org/repos/asf/allura/blob/221bded2/Allura/allura/tasks/mail_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/mail_tasks.py b/Allura/allura/tasks/mail_tasks.py
index 663c690..92c06e7 100644
--- a/Allura/allura/tasks/mail_tasks.py
+++ b/Allura/allura/tasks/mail_tasks.py
@@ -100,7 +100,7 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
         fromaddr = g.noreply
     elif not isinstance(fromaddr, basestring) or '@' not in fromaddr:
         log.warning('Looking up user with fromaddr: %s', fromaddr)
-        user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False)
+        user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False, pending=False)
         if not user:
             log.warning('Cannot find user with ID: %s', fromaddr)
             fromaddr = g.noreply
@@ -112,7 +112,7 @@ def sendmail(fromaddr, destinations, text, reply_to, subject,
             addrs_plain.append(addr)
         else:
             try:
-                user = M.User.query.get(_id=ObjectId(addr), disabled=False)
+                user = M.User.query.get(_id=ObjectId(addr), disabled=False, pending=False)
                 if not user:
                     log.warning('Cannot find user with ID: %s', addr)
                     continue
@@ -177,7 +177,7 @@ def sendsimplemail(
         fromaddr = g.noreply
     elif not isinstance(fromaddr, basestring) or '@' not in fromaddr:
         log.warning('Looking up user with fromaddr: %s', fromaddr)
-        user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False)
+        user = M.User.query.get(_id=ObjectId(fromaddr), disabled=False, pending=False)
         if not user:
             log.warning('Cannot find user with ID: %s', fromaddr)
             fromaddr = g.noreply
@@ -186,7 +186,7 @@ def sendsimplemail(
 
     if not isinstance(toaddr, basestring) or '@' not in toaddr:
         log.warning('Looking up user with toaddr: %s', toaddr)
-        user = M.User.query.get(_id=ObjectId(toaddr), disabled=False)
+        user = M.User.query.get(_id=ObjectId(toaddr), disabled=False, pending=False)
         if not user:
             log.warning('Cannot find user with ID: %s', toaddr)
             toaddr = g.noreply