Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6EDE8DCD2 for ; Tue, 16 Oct 2012 14:27:09 +0000 (UTC) Received: (qmail 22910 invoked by uid 500); 16 Oct 2012 14:27:09 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 22857 invoked by uid 500); 16 Oct 2012 14:27:09 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 22658 invoked by uid 99); 16 Oct 2012 14:27:08 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Oct 2012 14:27:08 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A0EE94784F; Tue, 16 Oct 2012 14:27:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: johnsca@apache.org To: allura-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [3/16] git commit: [#4990] ticket:181 fixed count labels error, added tests Message-Id: <20121016142708.A0EE94784F@tyr.zones.apache.org> Date: Tue, 16 Oct 2012 14:27:08 +0000 (UTC) [#4990] ticket:181 fixed count labels error, added tests Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/9a021b49 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9a021b49 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9a021b49 Branch: refs/heads/cj/5094 Commit: 9a021b4959e88ba494127bc738e0f3bba7a7f02e Parents: ba8af5c Author: Yuriy Arhipov Authored: Mon Oct 1 01:28:00 2012 +0400 Committer: Dave Brondsema Committed: Mon Oct 15 21:32:47 2012 +0000 ---------------------------------------------------------------------- .../forgewiki/templates/wiki/browse_tags.html | 2 +- ForgeWiki/forgewiki/tests/functional/test_root.py | 22 +++++++++++++++ ForgeWiki/forgewiki/wiki_main.py | 19 +++++++++---- 3 files changed, 36 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9a021b49/ForgeWiki/forgewiki/templates/wiki/browse_tags.html ---------------------------------------------------------------------- diff --git a/ForgeWiki/forgewiki/templates/wiki/browse_tags.html b/ForgeWiki/forgewiki/templates/wiki/browse_tags.html index 8f8c23a..76532f5 100644 --- a/ForgeWiki/forgewiki/templates/wiki/browse_tags.html +++ b/ForgeWiki/forgewiki/templates/wiki/browse_tags.html @@ -15,7 +15,7 @@ {% set i = 0 %} - {% for label in labels %} + {% for label in name_labels %} {{label}} http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9a021b49/ForgeWiki/forgewiki/tests/functional/test_root.py ---------------------------------------------------------------------- diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py index fa11a89..3375b6d 100644 --- a/ForgeWiki/forgewiki/tests/functional/test_root.py +++ b/ForgeWiki/forgewiki/tests/functional/test_root.py @@ -248,6 +248,28 @@ class TestRootController(TestController): 'viewable_by-0.id':'all'}) assert 'tést' in response + def test_page_label_count(self): + labels = "label" + for i in range(1, 100): + labels += ',label%s' % i + self.app.post( + '/wiki/tést/update', + params={ + 'title': 'tést', + 'text': 'sometext', + 'labels': labels, + 'labels_old': labels, + 'viewable_by-0.id': 'all'}) + r = self.app.get('/wiki/browse_tags/') + assert 'results of 100 ' in r + assert '
' in r + assert '(Page 1 of 4)' in r + assert 'label30' in r + assert 'label1' in r + r = self.app.get('/wiki/browse_tags/?page=3') + assert 'label77' in r + assert 'label99' in r + def test_new_attachment(self): self.app.post( '/wiki/tést/update', http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9a021b49/ForgeWiki/forgewiki/wiki_main.py ---------------------------------------------------------------------- diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py index ab56690..3528dd8 100644 --- a/ForgeWiki/forgewiki/wiki_main.py +++ b/ForgeWiki/forgewiki/wiki_main.py @@ -353,24 +353,31 @@ class RootController(BaseController, DispatchIndex): @expose('jinja:forgewiki:templates/wiki/browse_tags.html') @validate(dict(sort=validators.UnicodeString(if_empty='alpha'), page=validators.Int(if_empty=0), - limit=validators.Int(if_empty=None))) - def browse_tags(self, sort='alpha', page=0, limit=None): + limit=validators.Int(if_empty=25))) + def browse_tags(self, sort='alpha', page=0, limit=None, **kw): 'list of all labels in the wiki' c.page_list = W.page_list c.page_size = W.page_size limit, pagenum, start = g.handle_paging(limit, page, default=25) count = 0 page_tags = {} - q = WM.Page.query.find(dict(app_config_id=c.app.config._id, deleted=False)) - count = q.count() - q = q.skip(start).limit(int(limit)) + q = WM.Page.query.find(dict(app_config_id=c.app.config._id, + deleted=False, + labels={'$ne': []})) for page in q: if page.labels: for label in page.labels: if label not in page_tags: page_tags[label] = [] page_tags[label].append(page) - return dict(labels=page_tags, limit=limit, count=count, page=pagenum) + count = len(page_tags) + name_labels = list(page_tags) + name_labels.sort() + return dict(labels=page_tags, + limit=limit, + count=count, + page=pagenum, + name_labels=name_labels[start:start + limit]) @with_trailing_slash @expose('jinja:allura:templates/markdown_syntax.html')