You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/03/19 21:22:22 UTC
[01/10] allura git commit: [#7841] ticket:742 Hide disabled and
pending authors from wiki pages
Repository: allura
Updated Branches:
refs/heads/ib/7841 d1164fd0f -> f8348437a
refs/heads/master 970739581 -> 9c06caf76
[#7841] ticket:742 Hide disabled and pending authors from wiki pages
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/99dbd182
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/99dbd182
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/99dbd182
Branch: refs/heads/master
Commit: 99dbd182ede3641e896119e810efdec202c8dc7d
Parents: 5c8f832
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 00:13:19 2015 +0200
Committer: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Committed: Wed Mar 18 00:13:19 2015 +0200
----------------------------------------------------------------------
ForgeWiki/forgewiki/model/wiki.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/99dbd182/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index 18bfb85..c79fd16 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -234,7 +234,11 @@ class Page(VersionedArtifact, ActivityObject):
t[user.username] = user.id
return t.values()
user_ids = uniq([r.author for r in self.history().all()])
- return User.query.find({'_id': {'$in': user_ids}}).all()
+ return User.query.find({
+ '_id': {'$in': user_ids},
+ 'disabled': False,
+ 'pending': False
+ }).all()
def delete(self):
Shortlink.query.remove(dict(ref_id=self.index_id()))
[09/10] allura git commit: Merge branch 'ib/7841' of
https://git-wip-us.apache.org/repos/asf/allura into ib/7841
Posted by he...@apache.org.
Merge branch 'ib/7841' of https://git-wip-us.apache.org/repos/asf/allura into ib/7841
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/f8348437
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/f8348437
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/f8348437
Branch: refs/heads/ib/7841
Commit: f8348437a9c36dbc18e88ce868ed9fedd17ae36c
Parents: da74cea d1164fd
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Thu Mar 19 16:08:10 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 16:08:10 2015 -0400
----------------------------------------------------------------------
----------------------------------------------------------------------
[10/10] allura git commit: Merge branch 'ib/7841'
Posted by he...@apache.org.
Merge branch 'ib/7841'
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/9c06caf7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/9c06caf7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/9c06caf7
Branch: refs/heads/master
Commit: 9c06caf76aebb22d678813e743edd8d78f82eae0
Parents: 9707395 f834843
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Thu Mar 19 16:21:00 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 16:21:00 2015 -0400
----------------------------------------------------------------------
ForgeWiki/forgewiki/model/wiki.py | 6 ++++-
ForgeWiki/forgewiki/tests/test_models.py | 35 +++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[06/10] allura git commit: [#7841] ticket:742 Added test for
Page.authors
Posted by he...@apache.org.
[#7841] ticket:742 Added test for Page.authors
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/da74cead
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/da74cead
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/da74cead
Branch: refs/heads/ib/7841
Commit: da74cead74895c2420b47d092b7af629f97efe0f
Parents: e887dfb
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 16:02:05 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 14:51:21 2015 -0400
----------------------------------------------------------------------
ForgeWiki/forgewiki/tests/test_models.py | 35 +++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/da74cead/ForgeWiki/forgewiki/tests/test_models.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/test_models.py b/ForgeWiki/forgewiki/tests/test_models.py
index 5c10e50..2ab2f00 100644
--- a/ForgeWiki/forgewiki/tests/test_models.py
+++ b/ForgeWiki/forgewiki/tests/test_models.py
@@ -15,9 +15,15 @@
# specific language governing permissions and limitations
# under the License.
+from pylons import tmpl_context as c
+from ming.orm import session
+
from allura.tests import TestController
from allura.tests import decorators as td
from alluratest.controller import setup_global_objects
+from allura import model as M
+from allura.lib import helpers as h
+
from forgewiki.model import Page
@@ -59,3 +65,32 @@ class TestPageSnapshots(TestController):
page = Page.query.get(title='test-page')
# 10 changes by each thread + initial upsert
assert page.history().count() == 21, page.history().count()
+
+
+class TestPage(TestController):
+
+ @td.with_wiki
+ def test_authors(self):
+ user = M.User.by_username('test-user')
+ admin = M.User.by_username('test-admin')
+ with h.push_config(c, user=admin):
+ page = Page.upsert('test-admin')
+ page.text = 'admin'
+ page.commit()
+
+ with h.push_config(c, user=user):
+ page.text = 'user'
+ page.commit()
+
+ authors = page.authors()
+ assert len(authors) == 2
+ assert user in authors
+ assert admin in authors
+
+ user.disabled = True
+ session(user).flush(user)
+
+ authors = page.authors()
+ assert len(authors) == 1
+ assert user not in authors
+ assert admin in authors
[03/10] allura git commit: [#7072] Improve /auth/subscriptions
performance by avoiding mongo query in a loop (subscribed() method)
Posted by he...@apache.org.
[#7072] Improve /auth/subscriptions performance by avoiding mongo query in a loop (subscribed() method)
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/269703c5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/269703c5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/269703c5
Branch: refs/heads/ib/7841
Commit: 269703c5c510c6f9f0f58470fd9536172f0e5a24
Parents: 5c8f832
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Wed Mar 18 12:51:58 2015 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Mar 18 21:38:07 2015 +0000
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 66 ++++++++++++++++++++++------------
1 file changed, 44 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/269703c5/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 0bfe966..e874a17 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -829,6 +829,7 @@ class UserAvailabilityController(BaseController):
class SubscriptionsController(BaseController):
+ """ Gives users the ability to manage subscriptions to tools. """
def _check_security(self):
require_authenticated()
@@ -836,21 +837,25 @@ class SubscriptionsController(BaseController):
@with_trailing_slash
@expose('jinja:allura:templates/user_subs.html')
def index(self, **kw):
+ """ The subscription selection page in user preferences.
+
+ Builds up a list of dictionaries, each containing subscription
+ information about a tool.
+ """
c.form = F.subscription_form
c.revoke_access = F.oauth_revocation_form
+
subscriptions = []
- mailboxes = M.Mailbox.query.find(
- dict(user_id=c.user._id, is_flash=False))
- mailboxes = list(mailboxes.ming_cursor)
- project_collection = M.Project.query.mapper.collection
- app_collection = M.AppConfig.query.mapper.collection
+ mailboxes = list(M.Mailbox.query.find(
+ dict(user_id=c.user._id, is_flash=False)))
projects = dict(
- (p._id, p) for p in project_collection.m.find(dict(
+ (p._id, p) for p in M.Project.query.find(dict(
_id={'$in': [mb.project_id for mb in mailboxes]})))
app_index = dict(
- (ac._id, ac) for ac in app_collection.m.find(dict(
+ (ac._id, ac) for ac in M.AppConfig.query.find(dict(
_id={'$in': [mb.app_config_id for mb in mailboxes]})))
+ # Add the tools that are already subscribed to by the user.
for mb in mailboxes:
project = projects.get(mb.project_id, None)
app_config = app_index.get(mb.app_config_id, None)
@@ -859,8 +864,11 @@ class SubscriptionsController(BaseController):
continue
if app_config is None:
continue
+
subscriptions.append(dict(
subscription_id=mb._id,
+ project_id=project._id,
+ app_config_id=mb.app_config_id,
project_name=project.name,
mount_point=app_config.options['mount_point'],
artifact_title=dict(
@@ -871,24 +879,38 @@ class SubscriptionsController(BaseController):
artifact=mb.artifact_index_id,
subscribed=True))
+ # Dictionary of all projects projects accessible based on a users credentials (user_roles).
my_projects = dict((p._id, p) for p in c.user.my_projects())
- my_tools = app_collection.m.find(dict(
+
+ # Dictionary containing all tools (subscribed and un-subscribed).
+ my_tools = M.AppConfig.query.find(dict(
project_id={'$in': my_projects.keys()}))
+
+ # Dictionary containing all the currently subscribed tools for a given user.
+ my_tools_subscriptions = dict(
+ (mb.app_config_id, mb) for mb in M.Mailbox.query.find(dict(
+ user_id=c.user._id,
+ project_id={'$in': projects.keys()},
+ app_config_id={'$in': app_index.keys()},
+ artifact_index_id=None)))
+
+ # Add the remaining tools that are eligible for subscription.
for tool in my_tools:
- p_id = tool.project_id
- subscribed = M.Mailbox.subscribed(
- project_id=p_id, app_config_id=tool._id)
- if not subscribed:
- subscriptions.append(dict(
- tool_id=tool._id,
- project_id=p_id,
- project_name=my_projects[p_id].name,
- mount_point=tool.options['mount_point'],
- artifact_title='No subscription',
- topic=None,
- type=None,
- frequency=None,
- artifact=None))
+ if tool['_id'] in my_tools_subscriptions:
+ continue # We have already subscribed to this tool.
+
+ subscriptions.append(
+ dict(tool_id=tool._id,
+ user_id=c.user._id,
+ project_id=tool.project_id,
+ project_name=my_projects[tool.project_id].name,
+ mount_point=tool.options['mount_point'],
+ artifact_title='No subscription',
+ topic=None,
+ type=None,
+ frequency=None,
+ artifact=None))
+
subscriptions.sort(key=lambda d: (d['project_name'], d['mount_point']))
provider = plugin.AuthenticationProvider.get(request)
menu = provider.account_navigation()
[04/10] allura git commit: [#7841] ticket:742 Hide disabled and
pending authors from wiki pages
Posted by he...@apache.org.
[#7841] ticket:742 Hide disabled and pending authors from wiki pages
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/e887dfb5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e887dfb5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e887dfb5
Branch: refs/heads/ib/7841
Commit: e887dfb590badea3d6f893ae17c12a256eeac0c6
Parents: 269703c
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 00:13:19 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 14:51:21 2015 -0400
----------------------------------------------------------------------
ForgeWiki/forgewiki/model/wiki.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/e887dfb5/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index 18bfb85..c79fd16 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -234,7 +234,11 @@ class Page(VersionedArtifact, ActivityObject):
t[user.username] = user.id
return t.values()
user_ids = uniq([r.author for r in self.history().all()])
- return User.query.find({'_id': {'$in': user_ids}}).all()
+ return User.query.find({
+ '_id': {'$in': user_ids},
+ 'disabled': False,
+ 'pending': False
+ }).all()
def delete(self):
Shortlink.query.remove(dict(ref_id=self.index_id()))
[08/10] allura git commit: Merge branch 'ib/7841' of
https://git-wip-us.apache.org/repos/asf/allura into ib/7841
Posted by he...@apache.org.
Merge branch 'ib/7841' of https://git-wip-us.apache.org/repos/asf/allura into ib/7841
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/f8348437
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/f8348437
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/f8348437
Branch: refs/heads/master
Commit: f8348437a9c36dbc18e88ce868ed9fedd17ae36c
Parents: da74cea d1164fd
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Thu Mar 19 16:08:10 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 16:08:10 2015 -0400
----------------------------------------------------------------------
----------------------------------------------------------------------
[07/10] allura git commit: [#7841] ticket:742 Hide disabled and
pending authors from wiki pages
Posted by he...@apache.org.
[#7841] ticket:742 Hide disabled and pending authors from wiki pages
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/e887dfb5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e887dfb5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e887dfb5
Branch: refs/heads/master
Commit: e887dfb590badea3d6f893ae17c12a256eeac0c6
Parents: 269703c
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 00:13:19 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 14:51:21 2015 -0400
----------------------------------------------------------------------
ForgeWiki/forgewiki/model/wiki.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/e887dfb5/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index 18bfb85..c79fd16 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -234,7 +234,11 @@ class Page(VersionedArtifact, ActivityObject):
t[user.username] = user.id
return t.values()
user_ids = uniq([r.author for r in self.history().all()])
- return User.query.find({'_id': {'$in': user_ids}}).all()
+ return User.query.find({
+ '_id': {'$in': user_ids},
+ 'disabled': False,
+ 'pending': False
+ }).all()
def delete(self):
Shortlink.query.remove(dict(ref_id=self.index_id()))
[02/10] allura git commit: [#7841] ticket:742 Added test for
Page.authors
Posted by he...@apache.org.
[#7841] ticket:742 Added test for Page.authors
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/d1164fd0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d1164fd0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d1164fd0
Branch: refs/heads/master
Commit: d1164fd0fd80fc6546ab5f750cdae0066cea1982
Parents: 99dbd18
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 16:02:05 2015 +0200
Committer: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Committed: Wed Mar 18 16:02:05 2015 +0200
----------------------------------------------------------------------
ForgeWiki/forgewiki/tests/test_models.py | 35 +++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/d1164fd0/ForgeWiki/forgewiki/tests/test_models.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/test_models.py b/ForgeWiki/forgewiki/tests/test_models.py
index 5c10e50..2ab2f00 100644
--- a/ForgeWiki/forgewiki/tests/test_models.py
+++ b/ForgeWiki/forgewiki/tests/test_models.py
@@ -15,9 +15,15 @@
# specific language governing permissions and limitations
# under the License.
+from pylons import tmpl_context as c
+from ming.orm import session
+
from allura.tests import TestController
from allura.tests import decorators as td
from alluratest.controller import setup_global_objects
+from allura import model as M
+from allura.lib import helpers as h
+
from forgewiki.model import Page
@@ -59,3 +65,32 @@ class TestPageSnapshots(TestController):
page = Page.query.get(title='test-page')
# 10 changes by each thread + initial upsert
assert page.history().count() == 21, page.history().count()
+
+
+class TestPage(TestController):
+
+ @td.with_wiki
+ def test_authors(self):
+ user = M.User.by_username('test-user')
+ admin = M.User.by_username('test-admin')
+ with h.push_config(c, user=admin):
+ page = Page.upsert('test-admin')
+ page.text = 'admin'
+ page.commit()
+
+ with h.push_config(c, user=user):
+ page.text = 'user'
+ page.commit()
+
+ authors = page.authors()
+ assert len(authors) == 2
+ assert user in authors
+ assert admin in authors
+
+ user.disabled = True
+ session(user).flush(user)
+
+ authors = page.authors()
+ assert len(authors) == 1
+ assert user not in authors
+ assert admin in authors
[05/10] allura git commit: [#7841] ticket:742 Added test for
Page.authors
Posted by he...@apache.org.
[#7841] ticket:742 Added test for Page.authors
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/da74cead
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/da74cead
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/da74cead
Branch: refs/heads/master
Commit: da74cead74895c2420b47d092b7af629f97efe0f
Parents: e887dfb
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 16:02:05 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 14:51:21 2015 -0400
----------------------------------------------------------------------
ForgeWiki/forgewiki/tests/test_models.py | 35 +++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/da74cead/ForgeWiki/forgewiki/tests/test_models.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/test_models.py b/ForgeWiki/forgewiki/tests/test_models.py
index 5c10e50..2ab2f00 100644
--- a/ForgeWiki/forgewiki/tests/test_models.py
+++ b/ForgeWiki/forgewiki/tests/test_models.py
@@ -15,9 +15,15 @@
# specific language governing permissions and limitations
# under the License.
+from pylons import tmpl_context as c
+from ming.orm import session
+
from allura.tests import TestController
from allura.tests import decorators as td
from alluratest.controller import setup_global_objects
+from allura import model as M
+from allura.lib import helpers as h
+
from forgewiki.model import Page
@@ -59,3 +65,32 @@ class TestPageSnapshots(TestController):
page = Page.query.get(title='test-page')
# 10 changes by each thread + initial upsert
assert page.history().count() == 21, page.history().count()
+
+
+class TestPage(TestController):
+
+ @td.with_wiki
+ def test_authors(self):
+ user = M.User.by_username('test-user')
+ admin = M.User.by_username('test-admin')
+ with h.push_config(c, user=admin):
+ page = Page.upsert('test-admin')
+ page.text = 'admin'
+ page.commit()
+
+ with h.push_config(c, user=user):
+ page.text = 'user'
+ page.commit()
+
+ authors = page.authors()
+ assert len(authors) == 2
+ assert user in authors
+ assert admin in authors
+
+ user.disabled = True
+ session(user).flush(user)
+
+ authors = page.authors()
+ assert len(authors) == 1
+ assert user not in authors
+ assert admin in authors