You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/05/30 18:41:46 UTC

[01/24] git commit: [#6267] ticket:360 A little more tests for wiki api

Updated Branches:
  refs/heads/cj/6218 364cc72dd -> 253dbae1f (forced update)


[#6267] ticket:360 A little more tests for wiki api


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

Branch: refs/heads/cj/6218
Commit: 067705d61f4e28592a99904c007ea4be8a6eddce
Parents: a3e7f32
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri May 24 13:25:05 2013 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 27 09:02:18 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/functional/test_rest.py |   18 +++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/067705d6/ForgeWiki/forgewiki/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
index af1080a..f6f8714 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_rest.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -1,3 +1,4 @@
+# coding: utf-8
 import json
 
 from nose.tools import assert_equal
@@ -32,7 +33,11 @@ class TestWikiApi(TestRestApiBase):
         r = json.loads(r.body)
         assert_equal(len(r['attachments']), 2)
 
-    def test_post_page(self):
+    def test_page_does_not_exist(self):
+        r = self.api_get('/rest/p/test/wiki/fake/')
+        assert_equal(r.status_int, 404)
+
+    def test_update_page(self):
         data = {
             'text': 'Embrace the Dark Side',
             'labels': 'head hunting,dark side'
@@ -42,3 +47,14 @@ class TestWikiApi(TestRestApiBase):
         r = self.api_get('/rest/p/test/wiki/Home/')
         assert_equal(r.json['text'], data['text'])
         assert_equal(r.json['labels'], data['labels'].split(','))
+
+    def test_create_page(self):
+        data = {
+            'text': 'Embrace the Dark Side',
+            'labels': 'head hunting,dark side'
+        }
+        r = self.api_post(u'/rest/p/test/wiki/tést/'.encode('utf-8'), **data)
+        assert_equal(r.status_int, 200)
+        r = self.api_get(u'/rest/p/test/wiki/tést/'.encode('utf-8'))
+        assert_equal(r.json['text'], data['text'])
+        assert_equal(r.json['labels'], data['labels'].split(','))


[21/24] git commit: [#4994] Added more logging when sending notifications for debugging

Posted by jo...@apache.org.
[#4994] Added more logging when sending notifications for debugging

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: f3923bf2095afaf2f0c79f8da4f151560727a105
Parents: 9bc64c9
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed May 29 17:28:25 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed May 29 23:10:23 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/notification.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f3923bf2/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index 1ec530a..ebc0eef 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -237,6 +237,7 @@ class Notification(MappedClass):
     def send_direct(self, user_id):
         user = User.query.get(_id=ObjectId(user_id))
         artifact = self.ref.artifact
+        log.debug('Sending direct notification %s to user %s', self._id, user_id)
         # Don't send if user doesn't have read perms to the artifact
         if user and artifact and \
                 not security.has_access(artifact, 'read', user)():
@@ -265,6 +266,7 @@ class Notification(MappedClass):
                     security.has_access(artifact, 'read', user)()
         notifications = filter(perm_check, notifications)
 
+        log.debug('Sending digest of notifications [%s] to user %s', ', '.join([n._id for n in notifications]), user_id)
         if reply_to_address is None:
             reply_to_address = from_address
         text = [ 'Digest of %s' % subject ]
@@ -287,6 +289,7 @@ class Notification(MappedClass):
     @classmethod
     def send_summary(self, user_id, from_address, subject, notifications):
         if not notifications: return
+        log.debug('Sending summary of notifications [%s] to user %s', ', '.join([n._id for n in notifications]), user_id)
         text = [ 'Digest of %s' % subject ]
         for n in notifications:
             text.append('From: %s' % n.from_address)
@@ -453,7 +456,9 @@ class Mailbox(MappedClass):
             'artifact_index_id':{'$in':[None, artifact_index_id]},
             'topic':{'$in':[None, topic]}
             }
-        for mbox in cls.query.find(d):
+        mboxes = cls.query.find(d).all()
+        log.debug('Delivering notification %s to mailboxes [%s]', nid, ', '.join([str(m._id) for m in mboxes]))
+        for mbox in mboxes:
             try:
                 mbox.query.update(
                     {'$push':dict(queue=nid),
@@ -527,6 +532,7 @@ class Mailbox(MappedClass):
         '''
         notifications = Notification.query.find(dict(_id={'$in':self.queue}))
         notifications = notifications.all()
+        log.debug('Firing mailbox %s notifications [%s], found [%s]', str(self._id), ', '.join(self.queue), ', '.join([n._id for n in notifications]))
         if self.type == 'direct':
             ngroups = defaultdict(list)
             for n in notifications:


[03/24] git commit: [#6267] ticket:360 Restore wiki API POST functionality

Posted by jo...@apache.org.
[#6267] ticket:360 Restore wiki API POST functionality


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

Branch: refs/heads/cj/6218
Commit: a3e7f320c28c641fa60905af08120faac58e5457
Parents: 1af5b40
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri May 24 13:09:46 2013 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 27 09:02:18 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/wiki_main.py |   50 ++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a3e7f320/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 94f98a5..650d271 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -702,42 +702,40 @@ class RootRestController(BaseController):
         return PageRestController(title), remainder
 
 
-    @h.vardec
-    @expose()
-    @require_post()
-    def post(self, title, **post_data):
-        page = WM.Page.query.get(
-            app_config_id=c.app.config._id,
-            title=title,
-            deleted=False)
-        if not page:
-            require_access(c.app, 'create')
-            page = WM.Page.upsert(title)
-            page.viewable_by = ['all']
-        else:
-            require_access(page, 'edit')
-        page.text = post_data['text']
-        if 'labels' in post_data:
-            page.labels = post_data['labels'].split(',')
-        page.commit()
-
 class PageRestController(BaseController):
 
     def __init__(self, title):
-        if title is not None:
-            self.page = WM.Page.query.get(app_config_id=c.app.config._id,
-                                          title=h.really_unicode(unquote(title)),
-                                          deleted=False)
-            if self.page is None:
-                raise exc.HTTPNotFound()
+        self.title = h.really_unicode(unquote(title)) if title else None
+        self.page = WM.Page.query.get(app_config_id=c.app.config._id,
+                                      title=self.title,
+                                      deleted=False)
 
     def _check_security(self):
-        require_access(self.page, 'read')
+        if self.page:
+            require_access(self.page, 'read')
 
+    @h.vardec
     @expose('json:')
     def index(self, **kw):
+        if request.method == 'POST':
+            return self._update_page(self.title, **kw)
+        if self.page is None:
+            raise exc.HTTPNotFound()
         return self.page.__json__()
 
+    def _update_page(self, title, **post_data):
+        if not self.page:
+            require_access(c.app, 'create')
+            self.page = WM.Page.upsert(title)
+            self.page.viewable_by = ['all']
+        else:
+            require_access(self.page, 'edit')
+        self.page.text = post_data['text']
+        if 'labels' in post_data:
+            self.page.labels = post_data['labels'].split(',')
+        self.page.commit()
+        return {}
+
 
 class WikiAdminController(DefaultAdminController):
 


[22/24] git commit: [#6218] Get branches and tags directly from SCM

Posted by jo...@apache.org.
[#6218] Get branches and tags directly from SCM

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 0d33fc15757bd87bddb7b8b55fe16bff1750ec44
Parents: 956b6c5
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu May 23 23:35:00 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu May 30 16:41:26 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/repository.py                    |   27 +++++++++------
 Allura/allura/model/repository.py                  |   10 +++++
 ForgeGit/forgegit/model/git_repo.py                |    6 +++
 .../forgegit/tests/data/testgit.git/refs/tags/foo  |    1 +
 ForgeGit/forgegit/tests/model/test_repository.py   |   20 +++++++++++
 ForgeSVN/forgesvn/model/svn.py                     |    6 +++
 6 files changed, 59 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d33fc15/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 3a432ec..afd5557 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -130,29 +130,34 @@ class RepositoryApp(Application):
                         self.repo.upstream_repo.name + 'merge-requests/',
                         small=pending_upstream_merges))
         ref_url = self.repo.url_for_commit(self.default_branch_name, url_type='ref')
-        if self.repo.branches:
+        branches = self.repo.get_branches()
+        if branches:
             links.append(SitemapEntry('Branches'))
+            for branch in branches:
+                if branch.name == self.default_branch_name:
+                    branches.remove(branch)
+                    branches.insert(0, branch)
+                    break
             max_branches = 10
-            for b in self.repo.branches[:max_branches]:
+            for branch in branches[:max_branches]:
                 links.append(SitemapEntry(
-                        b.name,
-                        quote(self.repo.url_for_commit(b.name) + 'tree/'),
-                        small=b.count))
-            if len(self.repo.branches) > max_branches:
+                        branch.name,
+                        quote(self.repo.url_for_commit(branch.name) + 'tree/')))
+            if len(branches) > max_branches:
                 links.append(
                     SitemapEntry(
                         'More Branches',
                         ref_url + 'branches/',
                         ))
-        if self.repo.repo_tags:
+        tags = self.repo.get_tags()
+        if tags:
             links.append(SitemapEntry('Tags'))
             max_tags = 10
-            for b in self.repo.repo_tags[:max_tags]:
+            for b in tags[:max_tags]:
                 links.append(SitemapEntry(
                         b.name,
-                        quote(self.repo.url_for_commit(b.name) + 'tree/'),
-                        small=b.count))
-            if len(self.repo.repo_tags) > max_tags:
+                        quote(self.repo.url_for_commit(b.name) + 'tree/')))
+            if len(tags) > max_tags:
                 links.append(
                     SitemapEntry(
                         'More Tags',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d33fc15/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 37b95ab..b061cf2 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -214,6 +214,12 @@ class RepositoryImplementation(object):
         os.chmod(magic_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
         self._setup_hooks(source_path)
 
+    def get_branches(self):
+        return self.repo.branches
+
+    def get_tags(self):
+        return self.repo.tags
+
 class Repository(Artifact, ActivityObject):
     BATCH_SIZE=100
     class __mongometa__:
@@ -326,6 +332,10 @@ class Repository(Artifact, ActivityObject):
         return self._impl.last_commit_ids(commit, paths)
     def is_empty(self):
         return self._impl.is_empty()
+    def get_branches(self):
+        return self._impl.get_branches()
+    def get_tags(self):
+        return self._impl.get_tags()
 
     def _log(self, rev, skip, limit):
         head = self.commit(rev)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d33fc15/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index a9d16c0..8a2c074 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -361,6 +361,12 @@ class GitImplementation(M.RepositoryImplementation):
     def is_empty(self):
         return not self._git or len(self._git.heads) == 0
 
+    def get_branches(self):
+        return [Object(name=b.name,object_id=b.commit.hexsha) for b in self._git.heads]
+
+    def get_tags(self):
+        return [Object(name=t.name, object_id=t.commit.hexsha) for t in self._git.tags]
+
 
 class _OpenedGitBlob(object):
     CHUNK_SIZE=4096

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d33fc15/ForgeGit/forgegit/tests/data/testgit.git/refs/tags/foo
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/testgit.git/refs/tags/foo b/ForgeGit/forgegit/tests/data/testgit.git/refs/tags/foo
new file mode 100644
index 0000000..7e970a5
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/testgit.git/refs/tags/foo
@@ -0,0 +1 @@
+1e146e67985dcd71c74de79613719bef7bddca4a

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d33fc15/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 316f202..60bbd38 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -340,6 +340,26 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             ThreadLocalORMSession.flush_all()
             assert repo2.is_empty()
 
+class TestGitImplementation(unittest.TestCase):
+    def test_get_branches(self):
+        repo_dir = pkg_resources.resource_filename(
+            'forgegit', 'tests/data/testgit.git')
+        repo = mock.Mock(full_fs_path=repo_dir)
+        impl = GM.git_repo.GitImplementation(repo)
+        self.assertEqual(impl.get_branches(), [
+                Object(name='master', object_id='1e146e67985dcd71c74de79613719bef7bddca4a'),
+                Object(name='zz', object_id='5c47243c8e424136fd5cdd18cd94d34c66d1955c')
+            ])
+
+    def test_get_tags(self):
+        repo_dir = pkg_resources.resource_filename(
+            'forgegit', 'tests/data/testgit.git')
+        repo = mock.Mock(full_fs_path=repo_dir)
+        impl = GM.git_repo.GitImplementation(repo)
+        self.assertEqual(impl.get_tags(), [
+                Object(name='foo', object_id='1e146e67985dcd71c74de79613719bef7bddca4a'),
+            ])
+
 
 class TestGitCommit(unittest.TestCase):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d33fc15/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 2189a7f..db6de59 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -666,5 +666,11 @@ class SVNImplementation(M.RepositoryImplementation):
             else:
                 raise
 
+    def get_branches(self):
+        return []
+
+    def get_tags(self):
+        return []
+
 
 Mapper.compile_all()


[23/24] git commit: [#6218] Fixed failing test due to added tag

Posted by jo...@apache.org.
[#6218] Fixed failing test due to added tag

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 0b49c3358078674c007bd99df210667607d3a378
Parents: 0d33fc1
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri May 24 14:35:10 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu May 30 16:41:26 2013 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/tests/model/test_repository.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0b49c335/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 60bbd38..ba79ead 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -76,7 +76,7 @@ class TestNewGit(unittest.TestCase):
         assert self.rev.tree._id == self.rev.tree_id
         assert self.rev.summary == self.rev.message.splitlines()[0]
         assert self.rev.shorthand_id() == '[1e146e]'
-        assert self.rev.symbolic_ids == (['master', 'zz'], [])
+        assert self.rev.symbolic_ids == (['master', 'zz'], ['foo'])
         assert self.rev.url() == (
             '/p/test/src-git/ci/'
             '1e146e67985dcd71c74de79613719bef7bddca4a/')


[07/24] git commit: [#5913] Add summary and members to project header

Posted by jo...@apache.org.
[#5913] Add summary and members to project header

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: ddea323addab2b2043affd6ab667d14eeeff5f65
Parents: 067705d
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed May 15 21:48:34 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 29 18:40:17 2013 +0000

----------------------------------------------------------------------
 Allura/allura/templates/jinja_master/nav_menu.html |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ddea323a/Allura/allura/templates/jinja_master/nav_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html
index 76648a1..1b6a8f9 100644
--- a/Allura/allura/templates/jinja_master/nav_menu.html
+++ b/Allura/allura/templates/jinja_master/nav_menu.html
@@ -35,7 +35,7 @@
          {% endif %}
       </div>
   {% endif %}
-  <a href="{{c.project.url()}}">
+  <a href="{{c.project.url()}}" class="project_link">
     {% if c.project.user_project_of %}
       {{lib.gravatar(c.project.user_project_of, size=48, className='project_icon')}}
     {% elif c.project.icon %}
@@ -48,5 +48,16 @@
         {{c.project.name}}
       {% endif %}
 	</h1>
-	</a>
+        {{c.project.summary}}
+    </a>
+    <div class="brought-by{% if c.project.icon %} with-icon{% endif %}">
+        Brought to you by:
+        {% set users = c.project.users()|sort(attribute='display_name') %}
+        {% for user in users[:4] %}
+            <a href="{{ user.url() }}">{{ user.username }}</a>{{ ',' if not loop.last }}
+        {%- endfor -%}
+        {% if users|length > 4 -%}
+            , and <a href="{{ c.project.url() }}_members/">{{ users|length - 4 }} others</a>
+        {% endif %}
+    </div>
 {% endif %}


[15/24] git commit: [#5716] expose tool type in _nav.json

Posted by jo...@apache.org.
[#5716] expose tool type in _nav.json


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

Branch: refs/heads/cj/6218
Commit: 06d4a2a1d7f881a3a63a346136e3abb2f819d67a
Parents: 17c0937
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue May 28 19:07:16 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed May 29 19:01:56 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/project.py        |    5 +++--
 Allura/allura/tests/functional/test_home.py |    6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/06d4a2a1/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index cc80ad3..da39e5d 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -311,9 +311,10 @@ class ProjectController(FeedController):
     def _nav(self):
         menu = []
         for s in c.project.grouped_navbar_entries():
-            entry = dict(name=s.label, url=s.url, icon=s.ui_icon)
+            entry = dict(name=s.label, url=s.url, icon=s.ui_icon, tool_name=s.tool_name)
             if s.children:
-                entry['children'] = [dict(name=child.label, url=child.url, icon=child.ui_icon) for child in s.children]
+                entry['children'] = [dict(name=child.label, url=child.url, icon=child.ui_icon, tool_name=child.tool_name) 
+                                    for child in s.children]
             menu.append(entry)
         return dict(menu=menu)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/06d4a2a1/Allura/allura/tests/functional/test_home.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_home.py b/Allura/allura/tests/functional/test_home.py
index 3e11437..5e9ec2e 100644
--- a/Allura/allura/tests/functional/test_home.py
+++ b/Allura/allura/tests/functional/test_home.py
@@ -50,8 +50,8 @@ class TestProjectHome(TestController):
         response = self.app.get('/p/test/_nav.json')
         menu = response.json['menu']
         assert_equal(len(menu[1]['children']), 2)
-        assert {u'url': u'/p/test/wiki/', u'name': u'Wiki', u'icon': u'tool-wiki'} in menu[1]['children'], menu[1]['children']
-        assert {u'url': u'/p/test/wiki2/', u'name': u'wiki2', u'icon': u'tool-wiki'} in menu[1]['children'], menu[1]['children']
+        assert {u'url': u'/p/test/wiki/', u'name': u'Wiki', u'icon': u'tool-wiki', 'tool_name': 'wiki'} in menu[1]['children'], menu[1]['children']
+        assert {u'url': u'/p/test/wiki2/', u'name': u'wiki2', u'icon': u'tool-wiki', 'tool_name': 'wiki'} in menu[1]['children'], menu[1]['children']
 
     @td.with_wiki
     def test_project_group_nav_more_than_ten(self):
@@ -65,7 +65,7 @@ class TestProjectHome(TestController):
         response = self.app.get('/p/test/_nav.json')
         menu = response.json['menu']
         assert_equal(len(menu[1]['children']), 11)
-        assert {u'url': u'/p/test/_list/wiki', u'name': u'More...', u'icon': u'tool-wiki'} in menu[1]['children']
+        assert {u'url': u'/p/test/_list/wiki', u'name': u'More...', u'icon': u'tool-wiki', 'tool_name': 'wiki'} in menu[1]['children']
 
     @td.with_wiki
     def test_neighborhood_home(self):


[08/24] git commit: [#5913] Project header should show admins, not members

Posted by jo...@apache.org.
[#5913] Project header should show admins, not members

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 94029b503ab41d9b3b1f356b44c0d01750e81b1a
Parents: 2ff2b78
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue May 21 19:36:57 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 29 18:40:17 2013 +0000

----------------------------------------------------------------------
 Allura/allura/templates/jinja_master/nav_menu.html |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/94029b50/Allura/allura/templates/jinja_master/nav_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html
index 1b6a8f9..67c44ab 100644
--- a/Allura/allura/templates/jinja_master/nav_menu.html
+++ b/Allura/allura/templates/jinja_master/nav_menu.html
@@ -52,12 +52,12 @@
     </a>
     <div class="brought-by{% if c.project.icon %} with-icon{% endif %}">
         Brought to you by:
-        {% set users = c.project.users()|sort(attribute='display_name') %}
-        {% for user in users[:4] %}
-            <a href="{{ user.url() }}">{{ user.username }}</a>{{ ',' if not loop.last }}
+        {% set admins = c.project.admins()|sort(attribute='username') %}
+        {% for admin in admins[:4] %}
+            <a href="{{ admin.url() }}">{{ admin.username }}</a>{{ ',' if not loop.last }}
         {%- endfor -%}
-        {% if users|length > 4 -%}
-            , and <a href="{{ c.project.url() }}_members/">{{ users|length - 4 }} others</a>
+        {% if admins|length > 4 -%}
+            , and <a href="{{ c.project.url() }}_members/">{{ admins|length - 4 }} others</a>
         {% endif %}
     </div>
 {% endif %}


[20/24] git commit: [#4994] Fixed race condition when posting notifications

Posted by jo...@apache.org.
[#4994] Fixed race condition when posting notifications

If the thread that posts the notification takes a while to flush the
session (most easily seen on repo refreshes), then the Task can get
started before the new Notification instance is saved to mongo

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 956b6c5f19c92b59d61298c8f11f0166b807243b
Parents: f3923bf
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed May 29 22:58:40 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed May 29 23:10:23 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/notification.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/956b6c5f/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index ebc0eef..f5c9c6b 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -106,6 +106,8 @@ class Notification(MappedClass):
         import allura.tasks.notification_tasks
         n = cls._make_notification(artifact, topic, **kw)
         if n:
+            # make sure notification is flushed in time for task to process it
+            session(n).flush(n)
             allura.tasks.notification_tasks.notify.post(
                 n._id, artifact.index_id(), topic)
         return n
@@ -532,7 +534,10 @@ class Mailbox(MappedClass):
         '''
         notifications = Notification.query.find(dict(_id={'$in':self.queue}))
         notifications = notifications.all()
-        log.debug('Firing mailbox %s notifications [%s], found [%s]', str(self._id), ', '.join(self.queue), ', '.join([n._id for n in notifications]))
+        if len(notifications) != len(self.queue):
+            log.error('Mailbox queue error: Mailbox %s queued [%s], found [%s]', str(self._id), ', '.join(self.queue), ', '.join([n._id for n in notifications]))
+        else:
+            log.debug('Firing mailbox %s notifications [%s], found [%s]', str(self._id), ', '.join(self.queue), ', '.join([n._id for n in notifications]))
         if self.type == 'direct':
             ngroups = defaultdict(list)
             for n in notifications:


[06/24] git commit: [#5913] Add triangle to indicate nav menus with dropdowns

Posted by jo...@apache.org.
[#5913] Add triangle to indicate nav menus with dropdowns

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 2ff2b78620d6afee353e5575d72139de4071fd04
Parents: ddea323
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu May 16 13:43:09 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 29 18:40:17 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/project.py           |    2 +-
 Allura/allura/tests/unit/test_project.py |   18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2ff2b786/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index da36ada..e98b44c 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -498,7 +498,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
                 if tool_name not in grouped_nav:
                     child = deepcopy(e)
                     # change label to be the tool name (type)
-                    e.label = g.entry_points['tool'][tool_name].tool_label
+                    e.label = g.entry_points['tool'][tool_name].tool_label + u' \u25be'
                     # add tool url to list of urls that will match this nav entry
                     # have to do this before changing the url to the list page
                     e.matching_urls.append(e.url)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2ff2b786/Allura/allura/tests/unit/test_project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_project.py b/Allura/allura/tests/unit/test_project.py
index 7329dba..f83cfe9 100644
--- a/Allura/allura/tests/unit/test_project.py
+++ b/Allura/allura/tests/unit/test_project.py
@@ -38,10 +38,10 @@ class TestProject(unittest.TestCase):
         p.sitemap = Mock(return_value=sitemap_entries)
         entries = p.grouped_navbar_entries()
         expected = [
-            ('Tickets', 'proj_url/_list/tickets', 3),
-            ('wiki', 'wiki url', 0),
-            ('Discussion', 'proj_url/_list/discussion', 2),
-            ('subproject', 'subproject url', 0),
+            (u'Tickets \u25be', 'proj_url/_list/tickets', 3),
+            (u'wiki', 'wiki url', 0),
+            (u'Discussion \u25be', 'proj_url/_list/discussion', 2),
+            (u'subproject', 'subproject url', 0),
         ]
         expected_ticket_urls = ['bugs url', 'features url', 'support url']
         actual = [(e.label, e.url, len(e.matching_urls)) for e in entries]
@@ -64,11 +64,11 @@ class TestProject(unittest.TestCase):
         p.tool_data['allura'] = {'grouping_threshold': 2}
         entries = p.grouped_navbar_entries()
         expected = [
-            ('Tickets', 'proj_url/_list/tickets', 3),
-            ('wiki', 'wiki url', 0),
-            ('discuss', 'discuss url', 0),
-            ('subproject', 'subproject url', 0),
-            ('help', 'help url', 0),
+            (u'Tickets \u25be', 'proj_url/_list/tickets', 3),
+            (u'wiki', 'wiki url', 0),
+            (u'discuss', 'discuss url', 0),
+            (u'subproject', 'subproject url', 0),
+            (u'help', 'help url', 0),
         ]
         expected_ticket_urls = ['bugs url', 'features url', 'support url']
         actual = [(e.label, e.url, len(e.matching_urls)) for e in entries]


[11/24] git commit: [#5913] Fixed "and 1 others" corner-case on project header admin list

Posted by jo...@apache.org.
[#5913] Fixed "and 1 others" corner-case on project header admin list

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 4307a3da0ad469f1893e3382e9db0e1b3a11122d
Parents: f2af255
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu May 23 20:11:22 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 29 18:40:18 2013 +0000

----------------------------------------------------------------------
 Allura/allura/templates/jinja_master/nav_menu.html |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4307a3da/Allura/allura/templates/jinja_master/nav_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html
index 724ca1c..a34e20a 100644
--- a/Allura/allura/templates/jinja_master/nav_menu.html
+++ b/Allura/allura/templates/jinja_master/nav_menu.html
@@ -56,11 +56,12 @@
     <div class="brought-by{% if c.project.icon %} with-icon{% endif %}">
         Brought to you by:
         {% set admins = c.project.admins()|sort(attribute='username') %}
-        {% for admin in admins[:4] %}
-            <a href="{{ admin.url() }}">{{ admin.username }}</a>{{ ',' if not loop.last }}
+        {% for admin in admins[:5] %}
+            {% if loop.last and admins|length > 5 -%}
+                and <a href="{{ c.project.url() }}_members/">{{ admins|length - 4 }} others</a>
+            {% else %}
+                <a href="{{ admin.url() }}">{{ admin.username }}</a>{{ ',' if not loop.last }}
+            {% endif %}
         {%- endfor -%}
-        {% if admins|length > 4 -%}
-            , and <a href="{{ c.project.url() }}_members/">{{ admins|length - 4 }} others</a>
-        {% endif %}
     </div>
 {% endif %}


[19/24] git commit: [#4994] Fixed bug in direct notification accumulation that could cause missing notifications

Posted by jo...@apache.org.
[#4994] Fixed bug in direct notification accumulation that could cause missing notifications

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 9bc64c9bf99bc272e7b9862c8ff50432e2eb02db
Parents: aef20b8
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed May 29 16:38:28 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed May 29 23:10:23 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/notification.py            |    2 +-
 Allura/allura/tests/model/test_notification.py |   40 +++++++++++++++++++
 2 files changed, 41 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9bc64c9b/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index 61a5657..1ec530a 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -549,7 +549,7 @@ class Mailbox(MappedClass):
             for (subject, from_address, reply_to_address, author_id), ns in ngroups.iteritems():
                 try:
                     if len(ns) == 1:
-                        n.send_direct(self.user_id)
+                        ns[0].send_direct(self.user_id)
                     else:
                         Notification.send_digest(
                             self.user_id, from_address, subject, ns, reply_to_address)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9bc64c9b/Allura/allura/tests/model/test_notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_notification.py b/Allura/allura/tests/model/test_notification.py
index a894e20..6cdfbbb 100644
--- a/Allura/allura/tests/model/test_notification.py
+++ b/Allura/allura/tests/model/test_notification.py
@@ -17,10 +17,13 @@
 
 import unittest
 from datetime import timedelta
+import collections
 
 from pylons import tmpl_context as c, app_globals as g
 from nose.tools import assert_equal, assert_in
 from ming.orm import ThreadLocalORMSession
+import mock
+import bson
 
 from alluratest.controller import setup_basic_test, setup_global_objects, REGISTRY
 from allura import model as M
@@ -258,6 +261,43 @@ class TestSubscriptionTypes(unittest.TestCase):
     def _post_notification(self, text=None):
         return M.Notification.post(self.pg, 'metadata', text=text)
 
+    @mock.patch('allura.model.notification.defaultdict')
+    @mock.patch('allura.model.notification.Notification')
+    def test_direct_accumulation(self, mocked_notification, mocked_defaultdict):
+        class OrderedDefaultDict(collections.OrderedDict):
+            def __init__(self, factory=list, *a, **kw):
+                self._factory = factory
+                super(OrderedDefaultDict, self).__init__(*a, **kw)
+
+            def __getitem__(self, key):
+                if key not in self:
+                    value = self[key] = self._factory()
+                else:
+                    value = super(OrderedDefaultDict, self).__getitem__(key)
+                return value
+
+        notifications = mocked_notification.query.find.return_value.all.return_value = [
+                mock.Mock(_id='n0', topic='metadata', subject='s1', from_address='f1', reply_to_address='rt1', author_id='a1'),
+                mock.Mock(_id='n1', topic='metadata', subject='s2', from_address='f2', reply_to_address='rt2', author_id='a2'),
+                mock.Mock(_id='n2', topic='metadata', subject='s2', from_address='f2', reply_to_address='rt2', author_id='a2'),
+                mock.Mock(_id='n3', topic='message', subject='s3', from_address='f3', reply_to_address='rt3', author_id='a3'),
+                mock.Mock(_id='n4', topic='message', subject='s3', from_address='f3', reply_to_address='rt3', author_id='a3'),
+            ]
+        mocked_defaultdict.side_effect = OrderedDefaultDict
+
+        u0 = bson.ObjectId()
+        mbox = M.Mailbox(type='direct', user_id=u0, queue=['n0', 'n1', 'n2', 'n3', 'n4'])
+        mbox.fire('now')
+
+        mocked_notification.query.find.assert_called_once_with({'_id': {'$in': ['n0', 'n1', 'n2', 'n3', 'n4']}})
+        # first notification should be sent direct, as its key values are unique
+        notifications[0].send_direct.assert_called_once_with(u0)
+        # next two notifications should be sent as a digest as they have matching key values
+        mocked_notification.send_digest.assert_called_once_with(u0, 'f2', 's2', [notifications[1], notifications[2]], 'rt2')
+        # final two should be sent direct even though they matching keys, as they are messages
+        notifications[3].send_direct.assert_called_once_with(u0)
+        notifications[4].send_direct.assert_called_once_with(u0)
+
 def _clear_subscriptions():
         M.Mailbox.query.remove({})
 


[12/24] git commit: [#5913] Add development status badge to project header

Posted by jo...@apache.org.
[#5913] Add development status badge to project header

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 6618ababcf36eb31d0b85f662fa636a456af6be1
Parents: 88c6ce2
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue May 21 21:23:06 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 29 18:40:18 2013 +0000

----------------------------------------------------------------------
 Allura/allura/nf/allura/css/site_style.css         |   14 ++++++++++++++
 Allura/allura/templates/jinja_master/nav_menu.html |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6618abab/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 6623b94..b067f6d 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2099,6 +2099,7 @@ nav .ico {
   line-height: 1em;
   font-size: 32px;
   margin-bottom: 0;
+  display: inline;
 }
 
 #nav_menu_holder h1.project_title a,
@@ -2109,6 +2110,19 @@ nav .ico {
     text-decoration: none;
 }
 
+#nav_menu_holder #dev-status {
+    vertical-align: top;
+    text-transform: capitalize;
+    font-size: 10px;
+    -webkit-border-radius: 2px;
+    -moz-border-radius: 2px;
+    -o-border-radius: 2px;
+    border-radius: 2px;
+    background-color: #09c;
+    color: white;
+    padding: 2px;
+}
+
 #nav_menu_holder h2.project_summary {
   line-height: 1em;
   font-size: 16px;

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6618abab/Allura/allura/templates/jinja_master/nav_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html
index 27c7b56..74f7509 100644
--- a/Allura/allura/templates/jinja_master/nav_menu.html
+++ b/Allura/allura/templates/jinja_master/nav_menu.html
@@ -43,6 +43,11 @@
     <h1 class="project_title">
       <a href="{{c.project.url()}}" class="project_link">{{ c.project.neighborhood.name if c.project.is_nbhd_project else c.project.name }}</a>
     </h1>
+    {% set status = c.project.troves_by_type('developmentstatus')|sort(attribute='fullname') %}
+    {% set status = status[-1] %}
+    {% if status and status.shortname not in ['production', 'mature'] %}
+    <span id="dev-status" class="{{ status.shortname }}">{{ status.shortname }}</span>
+    {% endif %}
     <h2 class="project_summary">
         {{c.project.summary}}
     </h2>


[05/24] git commit: [#5913] Don't link entire project header

Posted by jo...@apache.org.
[#5913] Don't link entire project header

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: b667a6ded324d050d0468c7bb2d00e11a3856e0c
Parents: 94029b5
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue May 21 19:53:17 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 29 18:40:17 2013 +0000

----------------------------------------------------------------------
 Allura/allura/templates/jinja_master/nav_menu.html |   14 +++++---------
 1 files changed, 5 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b667a6de/Allura/allura/templates/jinja_master/nav_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html
index 67c44ab..15f7fac 100644
--- a/Allura/allura/templates/jinja_master/nav_menu.html
+++ b/Allura/allura/templates/jinja_master/nav_menu.html
@@ -35,21 +35,17 @@
          {% endif %}
       </div>
   {% endif %}
-  <a href="{{c.project.url()}}" class="project_link">
     {% if c.project.user_project_of %}
       {{lib.gravatar(c.project.user_project_of, size=48, className='project_icon')}}
     {% elif c.project.icon %}
       <img src="{{c.project.url()}}/icon?{{c.project.icon._id.generation_time}}" class="project_icon" alt="Project Logo">
     {% endif %}
-	<h1 class="project_title">
-      {% if c.project.is_nbhd_project %}
-        {{c.project.neighborhood.name}}
-      {% else %}
-        {{c.project.name}}
-      {% endif %}
-	</h1>
+    <h1 class="project_title">
+      <a href="{{c.project.url()}}" class="project_link">{{ c.project.neighborhood.name if c.project.is_nbhd_project else c.project.name }}</a>
+    </h1>
+    <h2>
         {{c.project.summary}}
-    </a>
+    </h2>
     <div class="brought-by{% if c.project.icon %} with-icon{% endif %}">
         Brought to you by:
         {% set admins = c.project.admins()|sort(attribute='username') %}


[02/24] git commit: [#6267] ticket:360 Test for wiki api post

Posted by jo...@apache.org.
[#6267] ticket:360 Test for wiki api post


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

Branch: refs/heads/cj/6218
Commit: 1af5b404be848880c79864a601e57c700029398c
Parents: 82f675f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri May 24 12:54:39 2013 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 27 09:02:18 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/functional/test_rest.py |   44 ++++++++++++++++
 ForgeWiki/forgewiki/tests/functional/test_root.py |   15 -----
 2 files changed, 44 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1af5b404/ForgeWiki/forgewiki/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
new file mode 100644
index 0000000..af1080a
--- /dev/null
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -0,0 +1,44 @@
+import json
+
+from nose.tools import assert_equal
+
+from allura.lib import helpers as h
+from allura.tests import decorators as td
+from alluratest.controller import TestRestApiBase
+
+
+class TestWikiApi(TestRestApiBase):
+
+    def setUp(self):
+        super(TestWikiApi, self).setUp()
+        self.setup_with_tools()
+
+    @td.with_wiki
+    def setup_with_tools(self):
+        h.set_context('test', 'wiki', neighborhood='Projects')
+
+    def test_get_page(self):
+        r = self.app.get('/p/test/wiki/Home/')
+        discussion_url = r.html.findAll('form')[2]['action'][:-4]
+        content = file(__file__).read()
+        self.app.post('/wiki/Home/attach', upload_files=[('file_info', 'test_root.py', content)])
+        r = self.app.get('/rest/p/test/wiki/Home/')
+        r = json.loads(r.body)
+        assert_equal(r['attachments'][0]['url'], 'http://localhost:80/p/test/wiki/Home/attachment/test_root.py')
+        assert_equal(r['discussion_thread_url'], 'http://localhost:80/rest%s' % discussion_url)
+        assert_equal(r['discussion_thread']['_id'], discussion_url.split('/')[-2])
+        self.app.post('/wiki/Home/attach', upload_files=[('file_info', '__init__.py', content),])
+        r = self.app.get('/rest/p/test/wiki/Home/')
+        r = json.loads(r.body)
+        assert_equal(len(r['attachments']), 2)
+
+    def test_post_page(self):
+        data = {
+            'text': 'Embrace the Dark Side',
+            'labels': 'head hunting,dark side'
+        }
+        r = self.api_post('/rest/p/test/wiki/Home/', **data)
+        assert_equal(r.status_int, 200)
+        r = self.api_get('/rest/p/test/wiki/Home/')
+        assert_equal(r.json['text'], data['text'])
+        assert_equal(r.json['labels'], data['labels'].split(','))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1af5b404/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 1baa28b..362d8bd 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -621,18 +621,3 @@ class TestRootController(TestController):
     def test_user_browse_page(self):
         r = self.app.get('/wiki/browse_pages/')
         assert '<td>Test Admin (test-admin)</td>' in r
-
-    def test_rest_wiki(self):
-        r = self.app.get('/p/test/wiki/Home/')
-        discussion_url = r.html.findAll('form')[2]['action'][:-4]
-        content = file(__file__).read()
-        self.app.post('/wiki/Home/attach', upload_files=[('file_info', 'test_root.py', content)])
-        r = self.app.get('/rest/p/test/wiki/Home/')
-        r = json.loads(r.body)
-        assert_equal(r['attachments'][0]['url'], 'http://localhost:80/p/test/wiki/Home/attachment/test_root.py')
-        assert_equal(r['discussion_thread_url'], 'http://localhost:80/rest%s' % discussion_url)
-        assert_equal(r['discussion_thread']['_id'], discussion_url.split('/')[-2])
-        self.app.post('/wiki/Home/attach', upload_files=[('file_info', '__init__.py', content),])
-        r = self.app.get('/rest/p/test/wiki/Home/')
-        r = json.loads(r.body)
-        assert_equal(len(r['attachments']), 2)


[13/24] git commit: [#5716] add support option for contacting members

Posted by jo...@apache.org.
[#5716] add support option for contacting members


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

Branch: refs/heads/cj/6218
Commit: 17c0937f958bdb7448e751fe8d12e7360264b5c7
Parents: 4307a3d
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue May 28 19:03:29 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed May 29 19:01:55 2013 +0000

----------------------------------------------------------------------
 .../templates/admin_widgets/metadata_admin.html    |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/17c0937f/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
index ff60ab3..c21bce8 100644
--- a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
@@ -41,7 +41,7 @@
     {{widget.display_field(widget.fields.short_description) }}
 
     <div style="clear:both">&nbsp;</div>
-    Support Page:
+    Preferred Support Page (for users of your project):
     <br>
     <input name="support_page" type="radio" value=""{% if value.support_page == '' %} checked{% endif %} id="support_page_none">
     <label for="support_page_none">None</label><br>
@@ -52,6 +52,8 @@
         <label for="support_page_{{ac.options.mount_point}}">{{ac.options.mount_label}}</label><br>
       {% endif %}
     {% endfor %}
+    <input name="support_page" type="radio" value="_members" {% if value.support_page == '_members' %} checked{% endif %} id="support_page_members">
+    <label for="support_page_members">Contact project admins</label><br>
     <input name="support_page" type="radio" value="_url" id="support_page_url_cb"
            {% if value.support_page == '_url' %} checked{% endif %}>
     <label for="support_page_url_cb">URL: </label>


[18/24] git commit: [#4994] Improved error checking around notifications to prevent lost notifications

Posted by jo...@apache.org.
[#4994] Improved error checking around notifications to prevent lost notifications

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: aef20b8c609832aec814eb5de27fbf617cc81f19
Parents: 4727a8b
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed May 29 15:44:24 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed May 29 23:10:23 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/notification.py |   67 +++++++++++++++++++++---------
 1 files changed, 47 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aef20b8c/Allura/allura/model/notification.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/notification.py b/Allura/allura/model/notification.py
index 3c3517f..61a5657 100644
--- a/Allura/allura/model/notification.py
+++ b/Allura/allura/model/notification.py
@@ -454,13 +454,20 @@ class Mailbox(MappedClass):
             'topic':{'$in':[None, topic]}
             }
         for mbox in cls.query.find(d):
-            mbox.query.update(
-                {'$push':dict(queue=nid),
-                 '$set':dict(last_modified=datetime.utcnow(),
-                             queue_empty=False),
-                })
-            # Make sure the mbox doesn't stick around to be flush()ed
-            session(mbox).expunge(mbox)
+            try:
+                mbox.query.update(
+                    {'$push':dict(queue=nid),
+                     '$set':dict(last_modified=datetime.utcnow(),
+                                 queue_empty=False),
+                    })
+                # Make sure the mbox doesn't stick around to be flush()ed
+                session(mbox).expunge(mbox)
+            except:
+                # log error but try to keep processing, lest all the other eligible
+                # mboxes for this notification get skipped and lost forever
+                log.exception(
+                    'Error adding notification: %s for artifact %s on project %s to user %s',
+                    nid, artifact_index_id, c.project._id, mbox.user_id)
 
     @classmethod
     def fire_ready(cls):
@@ -490,7 +497,11 @@ class Mailbox(MappedClass):
                 new=False)
 
         for mbox in take_while_true(find_and_modify_direct_mbox):
-            mbox.fire(now)
+            try:
+                mbox.fire(now)
+            except:
+                log.exception('Error firing mbox: %s with queue: [%s]', str(mbox._id), ', '.join(mbox.queue))
+                raise  # re-raise so we don't keep (destructively) trying to process mboxes
 
         for mbox in cls.query.find(q_digest):
             next_scheduled = now
@@ -519,20 +530,36 @@ class Mailbox(MappedClass):
         if self.type == 'direct':
             ngroups = defaultdict(list)
             for n in notifications:
-                if n.topic == 'message':
-                    n.send_direct(self.user_id)
-                    # Messages must be sent individually so they can be replied
-                    # to individually
-                else:
-                    key = (n.subject, n.from_address, n.reply_to_address, n.author_id)
-                    ngroups[key].append(n)
+                try:
+                    if n.topic == 'message':
+                        n.send_direct(self.user_id)
+                        # Messages must be sent individually so they can be replied
+                        # to individually
+                    else:
+                        key = (n.subject, n.from_address, n.reply_to_address, n.author_id)
+                        ngroups[key].append(n)
+                except:
+                    # log error but keep trying to deliver other notifications,
+                    # lest the other notifications (which have already been removed
+                    # from the mobx's queue in mongo) be lost
+                    log.exception(
+                        'Error sending notification: %s to mbox %s (user %s)',
+                        n._id, self._id, self.user_id)
             # Accumulate messages from same address with same subject
             for (subject, from_address, reply_to_address, author_id), ns in ngroups.iteritems():
-                if len(ns) == 1:
-                    n.send_direct(self.user_id)
-                else:
-                    Notification.send_digest(
-                        self.user_id, from_address, subject, ns, reply_to_address)
+                try:
+                    if len(ns) == 1:
+                        n.send_direct(self.user_id)
+                    else:
+                        Notification.send_digest(
+                            self.user_id, from_address, subject, ns, reply_to_address)
+                except:
+                    # log error but keep trying to deliver other notifications,
+                    # lest the other notifications (which have already been removed
+                    # from the mobx's queue in mongo) be lost
+                    log.exception(
+                        'Error sending notifications: [%s] to mbox %s (user %s)',
+                        ', '.join([n._id for n in ns]), self._id, self.user_id)
         elif self.type == 'digest':
             Notification.send_digest(
                 self.user_id, u'noreply@in.sf.net', 'Digest Email',


[17/24] git commit: [#5716] show URL validation errors on project metadata page

Posted by jo...@apache.org.
[#5716] show URL validation errors on project metadata page


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

Branch: refs/heads/cj/6218
Commit: 4c8116d2022ee6579f07935ff78e7de66a98b63a
Parents: 8fc7179
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed May 29 01:05:52 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed May 29 19:01:56 2013 +0000

----------------------------------------------------------------------
 .../templates/admin_widgets/metadata_admin.html    |   23 +++++++++------
 Allura/allura/ext/admin/widgets.py                 |   12 +++++--
 2 files changed, 22 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4c8116d2/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
index c21bce8..b37d638 100644
--- a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
@@ -21,11 +21,11 @@
     {{ widget.display_label(widget.fields.name) }}
     <br>
     {{widget.display_field(widget.fields.name) }}
-    {%if value.neighborhood.name != 'Users'%}
+    {%if c.project.neighborhood.name != 'Users'%}
     <label for="shortname">Unixname</label>
     <br>
     <input id="shortname" type="text" disabled="disabled"
-           value="{{value.shortname}}">
+           value="{{c.project.shortname}}">
 
     {{ widget.display_label(widget.fields.external_homepage) }}
     <br>
@@ -41,11 +41,13 @@
     {{widget.display_field(widget.fields.short_description) }}
 
     <div style="clear:both">&nbsp;</div>
-    Preferred Support Page (for users of your project):
-    <br>
+    Preferred Support Page (for users of your project):<br>
+    {% if c.form_errors.get('support_page_url') %}
+        <div class="error">{{c.form_errors.get('support_page_url')}}</div>
+    {% endif %}
     <input name="support_page" type="radio" value=""{% if value.support_page == '' %} checked{% endif %} id="support_page_none">
     <label for="support_page_none">None</label><br>
-    {% for ac in value.app_configs %}
+    {% for ac in c.project.app_configs %}
       {% if ac.tool_name.lower() in ['wiki', 'tickets', 'discussion'] %}
         <input name="support_page" type="radio" value="{{ac.options.mount_point}}" id="support_page_{{ac.options.mount_point}}"
                {% if value.support_page == ac.options.mount_point %} checked{% endif %}>
@@ -57,14 +59,14 @@
     <input name="support_page" type="radio" value="_url" id="support_page_url_cb"
            {% if value.support_page == '_url' %} checked{% endif %}>
     <label for="support_page_url_cb">URL: </label>
-    <input type="text" name="support_page_url" value="{{value.support_page_url}}" style="width: 70%">
+    <input type="text" name="support_page_url" value="{{value.support_page_url}}" style="width: 70%"><br>
     {{ widget.display_label(widget.fields.twitter_handle) }}
     <br>
     {{widget.display_field(widget.fields.twitter_handle) }}
     {{ widget.display_label(widget.fields.facebook_page) }}
     <br>
     {{widget.display_field(widget.fields.facebook_page) }}
-    {% if value.neighborhood.features['google_analytics'] %}
+    {% if c.project.neighborhood.features['google_analytics'] %}
     {{ widget.display_label(widget.fields.tracking_id) }}
     <br>
     {{widget.display_field(widget.fields.tracking_id) }}
@@ -94,7 +96,7 @@
           <input type="submit" value="Save" name="save" style="float: none" />
       </div>
     </div>
-    {%if value.neighborhood.name != 'Users'%}
+    {%if c.project.neighborhood.name != 'Users'%}
     <div style="clear:both">&nbsp;</div>
 
     <div id="project-status">
@@ -109,8 +111,11 @@
             Deleted
         {% endif %}
         <a href="#" title="Edit"><b data-icon="p" class="ico ico-pencil"></b></a>
-        <div id="project-status-edit" class="hidden">
+        <div id="project-status-edit" class="{% if not c.form_errors %}hidden{% endif %}">
             <br>
+            {% if c.form_errors.get('moved_to_url') %}
+                <div class="error">{{c.form_errors.get('moved_to_url')}}</div>
+            {% endif %}
             <input name="removal" type="radio" value="" id="removal_active_cb"
                    {% if value.removal == '' %} checked{% endif %}>
             <label for="removal_active_cb">Active Project</label>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4c8116d2/Allura/allura/ext/admin/widgets.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/widgets.py b/Allura/allura/ext/admin/widgets.py
index 8719c65..e663687 100644
--- a/Allura/allura/ext/admin/widgets.py
+++ b/Allura/allura/ext/admin/widgets.py
@@ -168,11 +168,14 @@ class MetadataAdmin(ff.AdminForm):
                                             V.MaxBytesValidator(max=1000)),
                                         attrs=dict(title="Add a few paragraphs describing your project to new users."))
         icon = ew.FileField(label='Icon')
-        external_homepage = ew.InputField(field_type="text", label='Homepage')
+        external_homepage = ew.InputField(field_type="text", label='Homepage',
+                                          validator=fev.URL(add_http=True))
         support_page = ew.InputField(field_type="text", label='Support Page')
-        support_page_url = ew.InputField(field_type="text", label='Support Page URL')
+        support_page_url = ew.InputField(field_type="text", label='Support Page URL',
+                                         validator=fev.URL(add_http=True, if_empty=''))
         removal = ew.InputField(field_type="text", label='Removal')
-        moved_to_url = ew.InputField(field_type="text", label='Moved Project to URL')
+        moved_to_url = ew.InputField(field_type="text", label='Moved Project to URL',
+                                     validator=fev.URL(add_http=True, if_empty=''))
         export_controlled = ew.InputField(field_type="text", label='Export Control')
         export_control_type = ew.InputField(field_type="text", label='Export Control Type')
         delete = ew.InputField(field_type="hidden", label='Delete')
@@ -180,7 +183,8 @@ class MetadataAdmin(ff.AdminForm):
         undelete = ew.InputField(field_type="hidden", label='Undelete')
         tracking_id = ew.InputField(field_type="text", label="Analytics Tracking ID")
         twitter_handle = ew.InputField(field_type="text", label='Twitter Handle')
-        facebook_page = ew.InputField(field_type="text", label='Facebook page')
+        facebook_page = ew.InputField(field_type="text", label='Facebook page',
+                                      validator=fev.URL(add_http=True))
 
 class AuditLog(ew_core.Widget):
     template='jinja:allura.ext.admin:templates/widgets/audit.html'


[10/24] git commit: [#5913] Minor IE fixes

Posted by jo...@apache.org.
[#5913] Minor IE fixes

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: f2af255e1028abfc59a115f16a7f2f71f0787012
Parents: 6fe0029
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed May 22 17:07:44 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 29 18:40:18 2013 +0000

----------------------------------------------------------------------
 Allura/allura/nf/allura/css/site_style.css |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f2af255e/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index cfbfc9e..b08330b 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2133,6 +2133,8 @@ nav .ico {
 }
 
 #nav_menu_holder #dev-status {
+    display: inline-block;
+    line-height: 1em;
     vertical-align: top;
     text-transform: capitalize;
     font-size: 10px;


[24/24] git commit: [#6218] Deprecated and removed references to cached heads, branches and tags

Posted by jo...@apache.org.
[#6218] Deprecated and removed references to cached heads, branches and tags

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 253dbae1f9b27ba9766a50018e6942edaba4d167
Parents: 0b49c33
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue May 28 19:26:58 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu May 30 16:41:27 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py            |   12 ++--
 Allura/allura/lib/repository.py                    |    2 +-
 Allura/allura/model/repository.py                  |   43 ++++++-------
 ForgeGit/forgegit/model/git_repo.py                |   51 +++++----------
 .../forgegit/tests/functional/test_controllers.py  |    2 +-
 ForgeGit/forgegit/tests/model/test_repository.py   |   21 ++----
 ForgeSVN/forgesvn/model/svn.py                     |   49 +++++++--------
 ForgeSVN/forgesvn/tests/model/test_repository.py   |    9 +--
 ForgeUserStats/forgeuserstats/tests/test_model.py  |    3 +-
 ForgeUserStats/forgeuserstats/tests/test_stats.py  |    3 +-
 10 files changed, 77 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 6967685..1279321 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -147,11 +147,11 @@ class RepoRootController(BaseController, FeedController):
     def mr_widget(self):
         source_branches = [
             b.name
-            for b in c.app.repo.branches + c.app.repo.repo_tags]
+            for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
         with c.app.repo.push_upstream_context():
             target_branches = [
                 b.name
-                for b in c.app.repo.branches + c.app.repo.repo_tags]
+                for b in c.app.repo.get_branches() + c.app.repo.get_tags()]
         return SCMMergeRequestWidget(
             source_branches=source_branches,
             target_branches=target_branches)
@@ -162,7 +162,7 @@ class RepoRootController(BaseController, FeedController):
         security.require(security.has_access(c.app.repo, 'admin'))
         c.form = self.mr_widget
         if branch is None:
-            source_branch=c.app.repo.branches[0].name
+            source_branch=c.app.default_branch_name
         return dict(source_branch=source_branch)
 
     @expose()
@@ -205,7 +205,7 @@ class RepoRootController(BaseController, FeedController):
     @without_trailing_slash
     @expose('json:')
     def commit_browser_data(self):
-        head_ids = [ head.object_id for head in c.app.repo.heads ]
+        head_ids = [ head.object_id for head in c.app.repo.get_heads() ]
         commit_ids = list(c.app.repo.commitlog(head_ids))
         log.info('Grab %d commit objects by ID', len(commit_ids))
         commits_by_id = dict(
@@ -394,12 +394,12 @@ class BranchBrowser(BaseController):
     @expose('jinja:allura:templates/repo/tags.html')
     @with_trailing_slash
     def tags(self, **kw):
-        return dict(tags=c.app.repo.repo_tags)
+        return dict(tags=c.app.repo.get_tags())
 
     @expose('jinja:allura:templates/repo/tags.html')
     @with_trailing_slash
     def branches(self, **kw):
-        return dict(title='Branches', tags=c.app.repo.branches)
+        return dict(title='Branches', tags=c.app.repo.get_branches())
 
     @expose()
     @with_trailing_slash

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index afd5557..5798b21 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -119,7 +119,7 @@ class RepositoryApp(Application):
                     (repo_path_parts[1], repo_path_parts[-1]),
                     self.repo.upstream_repo.name)
                 ]
-            if len(c.app.repo.branches) and has_access(c.app.repo, 'admin'):
+            if not c.app.repo.is_empty() and has_access(c.app.repo, 'admin'):
                 links.append(SitemapEntry('Request Merge', c.app.url + 'request_merge',
                              ui_icon=g.icons['merge'],
                              ))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index b061cf2..97b1799 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -92,10 +92,6 @@ class RepositoryImplementation(object):
         commit'''
         raise NotImplementedError, 'commit_parents'
 
-    def refresh_heads(self): # pragma no cover
-        '''Sets repository metadata such as heads, tags, and branches'''
-        raise NotImplementedError, 'refresh_heads'
-
     def refresh_commit_info(self, oid, lazy=True): # pragma no cover
         '''Refresh the data in the commit with id oid'''
         raise NotImplementedError, 'refresh_commit_info'
@@ -173,12 +169,8 @@ class RepositoryImplementation(object):
         return '[%s]' % oid[:6]
 
     def symbolics_for_commit(self, commit):
-        '''Return symbolic branch and tag names for a commit.
-        Default generic implementation is provided, subclasses
-        may override if they have more efficient means.'''
-        branches = [b.name for b in self._repo.branches if b.object_id == commit._id]
-        tags = [t.name for t in self._repo.repo_tags if t.object_id == commit._id]
-        return branches, tags
+        '''Return symbolic branch and tag names for a commit.'''
+        raise NotImplementedError, 'symbolics_for_commit'
 
     def url_for_commit(self, commit, url_type='ci'):
         'return an URL, given either a commit or object id'
@@ -214,11 +206,17 @@ class RepositoryImplementation(object):
         os.chmod(magic_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
         self._setup_hooks(source_path)
 
-    def get_branches(self):
-        return self.repo.branches
+    @property
+    def heads(self):
+        raise NotImplementedError, 'heads'
 
-    def get_tags(self):
-        return self.repo.tags
+    @property
+    def branches(self):
+        raise NotImplementedError, 'branches'
+
+    @property
+    def tags(self):
+        raise NotImplementedError, 'tags'
 
 class Repository(Artifact, ActivityObject):
     BATCH_SIZE=100
@@ -237,9 +235,9 @@ class Repository(Artifact, ActivityObject):
     status=FieldProperty(str)
     email_address=''
     additional_viewable_extensions=FieldProperty(str)
-    heads = FieldProperty([dict(name=str,object_id=str, count=int)])
-    branches = FieldProperty([dict(name=str,object_id=str, count=int)])
-    repo_tags = FieldProperty([dict(name=str,object_id=str, count=int)])
+    heads = FieldProperty(S.Deprecated)
+    branches = FieldProperty(S.Deprecated)
+    repo_tags = FieldProperty(S.Deprecated)
     upstream_repo = FieldProperty(dict(name=str,url=str))
 
     def __init__(self, **kw):
@@ -332,10 +330,12 @@ class Repository(Artifact, ActivityObject):
         return self._impl.last_commit_ids(commit, paths)
     def is_empty(self):
         return self._impl.is_empty()
+    def get_heads(self):
+        return self._impl.heads
     def get_branches(self):
-        return self._impl.get_branches()
+        return self._impl.branches
     def get_tags(self):
-        return self._impl.get_tags()
+        return self._impl.tags
 
     def _log(self, rev, skip, limit):
         head = self.commit(rev)
@@ -531,13 +531,8 @@ class Repository(Artifact, ActivityObject):
             log.info('... %r analyzing', self)
             self.status = 'analyzing'
             session(self).flush(self)
-            self._impl.refresh_heads()
             if asbool(tg.config.get('scm.new_refresh')):
                 refresh_repo(self, all_commits, notify, new_clone)
-            for head in self.heads + self.branches + self.repo_tags:
-                ci = self.commit(head.object_id)
-                if ci is not None:
-                    head.count = self.count_revisions(ci)
         finally:
             log.info('... %s ready', self)
             self.status = 'ready'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 8a2c074..cc1087b 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -148,13 +148,6 @@ class GitImplementation(M.RepositoryImplementation):
 
     def commit(self, rev):
         '''Return a Commit object.  rev can be _id or a branch/tag name'''
-        # See if the rev is a named ref that we have cached, and use the sha1
-        # from the cache. This ensures that we don't return a sha1 that we
-        # don't have indexed into mongo yet.
-        for ref in self._repo.heads + self._repo.branches + self._repo.repo_tags:
-            if ref.name == rev:
-                rev = ref.object_id
-                break
         cache = getattr(c, 'model_cache', '') or M.repo.ModelCache()
         result = cache.get(M.repo.Commit, dict(_id=rev))
         if result is None:
@@ -170,8 +163,8 @@ class GitImplementation(M.RepositoryImplementation):
                 except:
                     pass
                 log.exception('Error with rev_parse(%s)%s' % (str(rev) + '^0', url))
-        if result is None: return None
-        result.set_context(self._repo)
+        if result:
+            result.set_context(self._repo)
         return result
 
     def all_commit_ids(self):
@@ -189,7 +182,7 @@ class GitImplementation(M.RepositoryImplementation):
     def new_commits(self, all_commits=False):
         graph = {}
 
-        to_visit = [ self._git.commit(rev=hd.object_id) for hd in self._repo.heads ]
+        to_visit = [ self._git.commit(rev=hd.object_id) for hd in self.heads ]
         while to_visit:
             obj = to_visit.pop()
             if obj.hexsha in graph: continue
@@ -202,21 +195,6 @@ class GitImplementation(M.RepositoryImplementation):
             to_visit += obj.parents
         return list(topological_sort(graph))
 
-    def refresh_heads(self):
-        self._repo.heads = [
-            Object(name=head.name, object_id=head.commit.hexsha)
-            for head in self._git.heads
-            if head.is_valid() ]
-        self._repo.branches = [
-            Object(name=head.name, object_id=head.commit.hexsha)
-            for head in self._git.branches
-            if head.is_valid() ]
-        self._repo.repo_tags = [
-            Object(name=tag.name, object_id=tag.commit.hexsha)
-            for tag in self._git.tags
-            if tag.is_valid() ]
-        session(self._repo).flush()
-
     def refresh_commit_info(self, oid, seen, lazy=True):
         from allura.model.repo import CommitDoc
         ci_doc = CommitDoc.m.get(_id=oid)
@@ -331,13 +309,12 @@ class GitImplementation(M.RepositoryImplementation):
         return git.Object.new_from_sha(self._git, binsha)
 
     def symbolics_for_commit(self, commit):
-        branch_heads, tags = super(self.__class__, self).symbolics_for_commit(commit)
         try:
-            containing_branches = self._git.git.branch(contains=commit._id)
+            branches = [b.name for b in self.branches if b.object_id == commit._id]
+            tags = [t.name for t in self.tags if t.object_id == commit._id]
+            return branches, tags
         except git.GitCommandError:
-            return [], tags
-        containing_branches = [br.strip(' *') for br in containing_branches.split('\n')]
-        return containing_branches, tags
+            return [], []
 
     def compute_tree_new(self, commit, tree_path='/'):
         ci = self._git.rev_parse(commit._id)
@@ -361,11 +338,17 @@ class GitImplementation(M.RepositoryImplementation):
     def is_empty(self):
         return not self._git or len(self._git.heads) == 0
 
-    def get_branches(self):
-        return [Object(name=b.name,object_id=b.commit.hexsha) for b in self._git.heads]
+    @LazyProperty
+    def heads(self):
+        return [Object(name=b.name, object_id=b.commit.hexsha) for b in self._git.heads if b.is_valid()]
+
+    @LazyProperty
+    def branches(self):
+        return [Object(name=b.name, object_id=b.commit.hexsha) for b in self._git.branches if b.is_valid()]
 
-    def get_tags(self):
-        return [Object(name=t.name, object_id=t.commit.hexsha) for t in self._git.tags]
+    @LazyProperty
+    def tags(self):
+        return [Object(name=t.name, object_id=t.commit.hexsha) for t in self._git.tags if t.is_valid()]
 
 
 class _OpenedGitBlob(object):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 787cef1..1aa10e2 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -466,7 +466,7 @@ class TestFork(_TestCase):
         assert 'Improve documentation' in r, r.showbrowser()
         revs = r.html.findAll('tr', attrs={'class': 'rev'})
         links = revs[0].findAll('a')
-        c_id = self.forked_repo.heads[0]['object_id']
+        c_id = self.forked_repo.get_heads()[0]['object_id']
         assert_equal(links[0].get('href'), '/p/test2/code/ci/%s/' % c_id)
         assert_equal(links[0].getText(), '[%s]' % c_id[:6])
         assert_equal(links[1].get('href'), '/p/test2/code/ci/%s/tree' % c_id)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index ba79ead..a03650d 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -63,8 +63,7 @@ class TestNewGit(unittest.TestCase):
         #     tool = 'git',
         #     status = 'creating')
         self.repo.refresh()
-        self.rev = M.repo.Commit.query.get(_id=self.repo.heads[0]['object_id'])
-        self.rev.repo = self.repo
+        self.rev = self.repo.commit('master')
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
 
@@ -76,7 +75,7 @@ class TestNewGit(unittest.TestCase):
         assert self.rev.tree._id == self.rev.tree_id
         assert self.rev.summary == self.rev.message.splitlines()[0]
         assert self.rev.shorthand_id() == '[1e146e]'
-        assert self.rev.symbolic_ids == (['master', 'zz'], ['foo'])
+        assert self.rev.symbolic_ids == (['master'], ['foo']), self.rev.symbolic_ids
         assert self.rev.url() == (
             '/p/test/src-git/ci/'
             '1e146e67985dcd71c74de79613719bef7bddca4a/')
@@ -234,12 +233,6 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         entry = self.repo.commit('HEAD')
         assert str(entry.authored.name) == 'Rick Copeland', entry.authored
         assert entry.message
-        # Test that sha1s for named refs are looked up in cache first, instead
-        # of from disk.
-        with mock.patch('forgegit.model.git_repo.M.repo.Commit.query') as q:
-            self.repo.heads.append(Object(name='HEAD', object_id='deadbeef'))
-            self.repo.commit('HEAD')
-            q.get.assert_called_with(_id='deadbeef')
         # test the auto-gen tree fall-through
         orig_tree = M.repo.Tree.query.get(_id=entry.tree_id)
         assert orig_tree
@@ -265,7 +258,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         notifications = M.Notification.query.find().sort('pubdate')
         n = notifications.all()[2]
         assert_equal(n.subject, '[test:src-git] [1e146e] - Rick Copeland: Change README')
-        assert 'master,zz: ' in n.text
+        assert 'master: ' in n.text
         send_notifications(self.repo, ['1e146e67985dcd71c74de79613719bef7bddca4a', 'df30427c488aeab84b2352bdf88a3b19223f9d7a'])
         ThreadLocalORMSession.flush_all()
         notifications = M.Notification.query.find().sort('pubdate')
@@ -341,22 +334,22 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             assert repo2.is_empty()
 
 class TestGitImplementation(unittest.TestCase):
-    def test_get_branches(self):
+    def test_branches(self):
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data/testgit.git')
         repo = mock.Mock(full_fs_path=repo_dir)
         impl = GM.git_repo.GitImplementation(repo)
-        self.assertEqual(impl.get_branches(), [
+        self.assertEqual(impl.branches, [
                 Object(name='master', object_id='1e146e67985dcd71c74de79613719bef7bddca4a'),
                 Object(name='zz', object_id='5c47243c8e424136fd5cdd18cd94d34c66d1955c')
             ])
 
-    def test_get_tags(self):
+    def test_tags(self):
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data/testgit.git')
         repo = mock.Mock(full_fs_path=repo_dir)
         impl = GM.git_repo.GitImplementation(repo)
-        self.assertEqual(impl.get_tags(), [
+        self.assertEqual(impl.tags, [
                 Object(name='foo', object_id='1e146e67985dcd71c74de79613719bef7bddca4a'),
             ])
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index db6de59..78013d4 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -98,8 +98,7 @@ class Repository(M.Repository):
 
     def latest(self, branch=None):
         if self._impl is None: return None
-        if not self.heads: return None
-        return self._impl.commit(self.heads[0].object_id)
+        return self._impl.commit('HEAD')
 
 
 class SVNCalledProcessError(Exception):
@@ -289,42 +288,27 @@ class SVNImplementation(M.RepositoryImplementation):
             c.app.config.options['checkout_url'] = ""
         self._setup_special_files(source_url)
 
-    def refresh_heads(self):
-        info = self._svn.info2(
-            self._url,
-            revision=pysvn.Revision(pysvn.opt_revision_kind.head),
-            recurse=False)[0][1]
-        oid = self._oid(info.rev.number)
-        self._repo.heads = [ Object(name=None, object_id=oid) ]
-        # Branches and tags aren't really supported in subversion
-        self._repo.branches = []
-        self._repo.repo_tags = []
-        session(self._repo).flush(self._repo)
-
     def commit(self, rev):
         if rev in ('HEAD', None):
-            if not self._repo.heads: return None
-            oid = self._repo.heads[0].object_id
+            oid = self._oid(self.head)
         elif isinstance(rev, int) or rev.isdigit():
             oid = self._oid(rev)
         else:
             oid = rev
         result = M.repo.Commit.query.get(_id=oid)
-        if result is None: return None
-        result.set_context(self._repo)
+        if result:
+            result.set_context(self._repo)
         return result
 
     def all_commit_ids(self):
         """Return a list of commit ids, starting with the head (most recent
         commit) and ending with the root (first commit).
         """
-        if not self._repo.heads:
-            return []
-        head_revno = self._revno(self._repo.heads[0].object_id)
+        head_revno = self.head
         return map(self._oid, range(head_revno, 0, -1))
 
     def new_commits(self, all_commits=False):
-        head_revno = self._revno(self._repo.heads[0].object_id)
+        head_revno = self.head
         oids = [ self._oid(revno) for revno in range(1, head_revno+1) ]
         if all_commits:
             return oids
@@ -657,19 +641,32 @@ class SVNImplementation(M.RepositoryImplementation):
                 os.remove(tmpfilename)
 
     def is_empty(self):
+        return self.head == 0
+
+    def symbolics_for_commit(self, commit):
+        return [], []
+
+    @LazyProperty
+    def head(self):
         try:
-            return self._svn.revpropget('revision', url=self._url)[0].number == 0
+            return int(self._svn.revpropget('revision', url=self._url)[0].number)
         except pysvn.ClientError as e:
             if str(e).startswith("Unable to connect") or \
                     str(e).startswith("Unable to open"):
-                return True
+                return 0
             else:
                 raise
 
-    def get_branches(self):
+    @LazyProperty
+    def heads(self):
+        return [Object(name=None, object_id=self._oid(self.head))]
+
+    @LazyProperty
+    def branches(self):
         return []
 
-    def get_tags(self):
+    @LazyProperty
+    def tags(self):
         return []
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 6026125..3e25154 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -64,8 +64,7 @@ class TestNewRepo(unittest.TestCase):
             tool = 'svn',
             status = 'creating')
         self.repo.refresh()
-        self.rev = M.repo.Commit.query.get(_id=self.repo.heads[0]['object_id'])
-        self.rev.repo = self.repo
+        self.rev = self.repo.commit('HEAD')
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
 
@@ -604,10 +603,7 @@ class TestRepo(_TestWithRepo):
                         name=committer_name,
                         email=committer_email),
                     _id=oid)).m.insert()
-        def set_heads():
-            self.repo.heads = [ ming.base.Object(name='head', object_id='foo0', count=100) ]
         self.repo._impl.refresh_commit_info = refresh_commit_info
-        self.repo._impl.refresh_heads = mock.Mock(side_effect=set_heads)
         _id = lambda oid: getattr(oid, '_id', str(oid))
         self.repo.shorthand_for_commit = lambda oid: '[' + _id(oid) + ']'
         self.repo.url_for_commit = lambda oid: 'ci/' + _id(oid) + '/'
@@ -628,9 +624,6 @@ class TestRepo(_TestWithRepo):
         self.repo.count_revisions=mock.Mock(return_value=100)
         self.repo._impl.commit = mock.Mock(return_value=ci)
         self.repo._impl.new_commits = mock.Mock(return_value=['foo%d' % i for i in range(100) ])
-        def set_heads():
-            self.repo.heads = [ ming.base.Object(name='head', object_id='foo0', count=100) ]
-        self.repo._impl.refresh_heads = mock.Mock(side_effect=set_heads)
 
         # make unreadable by *anonymous, so additional notification logic executes
         self.repo.acl = []

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/ForgeUserStats/forgeuserstats/tests/test_model.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/tests/test_model.py b/ForgeUserStats/forgeuserstats/tests/test_model.py
index cc67e27..a6526e1 100644
--- a/ForgeUserStats/forgeuserstats/tests/test_model.py
+++ b/ForgeUserStats/forgeuserstats/tests/test_model.py
@@ -337,8 +337,7 @@ class TestUserStats(unittest.TestCase):
         c.app.repo.name = 'testgit.git'
         repo = c.app.repo
         repo.refresh()
-        commit = M.repo.Commit.query.get(_id=repo.heads[0]['object_id'])
-        commit.repo = repo
+        commit = repo.commit()
 
         init_commits = self.user.stats.getCommits()
         assert init_commits['number'] == 4

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/253dbae1/ForgeUserStats/forgeuserstats/tests/test_stats.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/tests/test_stats.py b/ForgeUserStats/forgeuserstats/tests/test_stats.py
index fad927c..326ae07 100644
--- a/ForgeUserStats/forgeuserstats/tests/test_stats.py
+++ b/ForgeUserStats/forgeuserstats/tests/test_stats.py
@@ -191,8 +191,7 @@ class TestGitCommit(unittest.TestCase, TestController):
         c.app.repo.name = 'testgit.git'
         self.repo = c.app.repo
         self.repo.refresh()
-        self.rev = M.repo.Commit.query.get(_id=self.repo.heads[0]['object_id'])
-        self.rev.repo = self.repo
+        self.rev = self.repo.commit()
 
     @td.with_user_project('test-admin')
     def test_commit(self):


[14/24] git commit: [#5716] make project admin's support choices configurable, and off by default

Posted by jo...@apache.org.
[#5716] make project admin's support choices configurable, and off by default


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

Branch: refs/heads/cj/6218
Commit: 4727a8b983e8220c8d2a36f9be761f72be2549fb
Parents: 4c8116d
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed May 29 14:08:58 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed May 29 19:01:56 2013 +0000

----------------------------------------------------------------------
 .../templates/admin_widgets/metadata_admin.html    |    6 +++++-
 Allura/development.ini                             |    6 ++++++
 Allura/test.ini                                    |    2 ++
 3 files changed, 13 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4727a8b9/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
index b37d638..454f33a 100644
--- a/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
+++ b/Allura/allura/ext/admin/templates/admin_widgets/metadata_admin.html
@@ -41,6 +41,8 @@
     {{widget.display_field(widget.fields.short_description) }}
 
     <div style="clear:both">&nbsp;</div>
+    
+    {% if tg.config.get('support_tool_choices') %}
     Preferred Support Page (for users of your project):<br>
     {% if c.form_errors.get('support_page_url') %}
         <div class="error">{{c.form_errors.get('support_page_url')}}</div>
@@ -48,7 +50,7 @@
     <input name="support_page" type="radio" value=""{% if value.support_page == '' %} checked{% endif %} id="support_page_none">
     <label for="support_page_none">None</label><br>
     {% for ac in c.project.app_configs %}
-      {% if ac.tool_name.lower() in ['wiki', 'tickets', 'discussion'] %}
+      {% if ac.tool_name.lower() in tg.config['support_tool_choices'].split() %}
         <input name="support_page" type="radio" value="{{ac.options.mount_point}}" id="support_page_{{ac.options.mount_point}}"
                {% if value.support_page == ac.options.mount_point %} checked{% endif %}>
         <label for="support_page_{{ac.options.mount_point}}">{{ac.options.mount_label}}</label><br>
@@ -60,6 +62,8 @@
            {% if value.support_page == '_url' %} checked{% endif %}>
     <label for="support_page_url_cb">URL: </label>
     <input type="text" name="support_page_url" value="{{value.support_page_url}}" style="width: 70%"><br>
+    {% endif %}
+
     {{ widget.display_label(widget.fields.twitter_handle) }}
     <br>
     {{widget.display_field(widget.fields.twitter_handle) }}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4727a8b9/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index cdde88e..b3c084f 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -141,6 +141,12 @@ scm.repos.tarball.root = /usr/share/nginx/www/
 scm.repos.tarball.url_prefix = http://localhost/
 scm.repos.tarball.zip_binary = /usr/bin/zip
 
+# space-separated list of tool names that are valid options
+# for project admins to set for their 'support_page' field
+# this field is not used by default in Allura, so this option
+# is disabled by default
+#support_tool_choices = wiki tickets discussion
+
 trovecategories.enableediting = true
 
 # ActivityStream

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4727a8b9/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index f749705..b3d9760 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -101,6 +101,8 @@ scm.repos.tarball.enable = true
 scm.repos.tarball.root = /tmp/tarball
 scm.repos.tarball.url_prefix = file://
 
+support_tool_choices = wiki tickets discussion
+
 #stats.sample_rate = 0
 
 disable_csrf_protection=1


[04/24] git commit: [#5913] Fixed styling of new project header

Posted by jo...@apache.org.
[#5913] Fixed styling of new project header

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 88c6ce258bc7bbee91b35c5d29a9fb1c6bec6be3
Parents: b667a6d
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue May 21 20:31:22 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 29 18:40:17 2013 +0000

----------------------------------------------------------------------
 Allura/allura/nf/allura/css/site_style.css         |   29 ++++++++++++++-
 Allura/allura/templates/jinja_master/nav_menu.html |    2 +-
 2 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88c6ce25/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 06b93ca..6623b94 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2091,8 +2091,33 @@ nav .ico {
   vertical-align: middle;
 }
 
-.project_title {
-  line-height: 48px;
+#nav_menu_holder {
+    margin: 0 0 15px;
+}
+
+#nav_menu_holder h1.project_title {
+  line-height: 1em;
+  font-size: 32px;
+  margin-bottom: 0;
+}
+
+#nav_menu_holder h1.project_title a,
+#nav_menu_holder h1.project_title a:hover,
+#nav_menu_holder h1.project_title a:visited,
+#nav_menu_holder h1.project_title a:focus {
+    color: #555;
+    text-decoration: none;
+}
+
+#nav_menu_holder h2.project_summary {
+  line-height: 1em;
+  font-size: 16px;
+  font-weight: normal;
+  margin-bottom: 0;
+}
+
+#nav_menu_holder .brought-by.with-icon {
+  margin-left: 55px;
 }
 
 .neighborhood_icon {

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88c6ce25/Allura/allura/templates/jinja_master/nav_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html
index 15f7fac..27c7b56 100644
--- a/Allura/allura/templates/jinja_master/nav_menu.html
+++ b/Allura/allura/templates/jinja_master/nav_menu.html
@@ -43,7 +43,7 @@
     <h1 class="project_title">
       <a href="{{c.project.url()}}" class="project_link">{{ c.project.neighborhood.name if c.project.is_nbhd_project else c.project.name }}</a>
     </h1>
-    <h2>
+    <h2 class="project_summary">
         {{c.project.summary}}
     </h2>
     <div class="brought-by{% if c.project.icon %} with-icon{% endif %}">


[09/24] git commit: [#5913] Added breadcrumb navigation to project header

Posted by jo...@apache.org.
[#5913] Added breadcrumb navigation to project header

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/6218
Commit: 6fe002974a5ad4425c350ac2990b14dfa87d612f
Parents: 6618aba
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue May 21 23:18:06 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 29 18:40:18 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/project.py                     |   18 ++++++++++++
 Allura/allura/nf/allura/css/site_style.css         |   22 +++++++++++++++
 Allura/allura/templates/jinja_master/nav_menu.html |    2 +
 .../templates/jinja_master/theme_macros.html       |   18 ++++++++++++
 4 files changed, 60 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6fe00297/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index e98b44c..c11c148 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -117,6 +117,24 @@ class TroveCategory(MappedClass):
             trove = trove.parent_category
         return trove.shortname
 
+    @LazyProperty
+    def ancestors(self):
+        ancestors = []
+        trove = self
+        while trove:
+            ancestors.append(trove)
+            trove = trove.parent_category
+        return ancestors
+
+    @LazyProperty
+    def breadcrumbs(self):
+        url = '/directory/'
+        crumbs = []
+        for trove in reversed(self.ancestors[:-1]):
+            url += trove.shortname + '/'
+            crumbs.append((trove.fullname, url))
+        return crumbs
+
 class ProjectMapperExtension(MapperExtension):
     def after_insert(self, obj, st, sess):
         g.zarkov_event('project_create', project=obj)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6fe00297/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index b067f6d..cfbfc9e 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2095,6 +2095,28 @@ nav .ico {
     margin: 0 0 15px;
 }
 
+#nav_menu_holder #breadcrumbs {
+    margin-bottom: 5px;
+}
+
+#nav_menu_holder #breadcrumbs ul {
+    list-style: none;
+    margin: 0;
+}
+
+#nav_menu_holder #breadcrumbs li {
+    display: inline;
+    font-size: 11px;
+}
+
+#nav_menu_holder #breadcrumbs li:after {
+    content: ' / ';
+}
+
+#nav_menu_holder #breadcrumbs li:last-child:after {
+    content: '';
+}
+
 #nav_menu_holder h1.project_title {
   line-height: 1em;
   font-size: 32px;

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6fe00297/Allura/allura/templates/jinja_master/nav_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html
index 74f7509..724ca1c 100644
--- a/Allura/allura/templates/jinja_master/nav_menu.html
+++ b/Allura/allura/templates/jinja_master/nav_menu.html
@@ -17,10 +17,12 @@
        under the License.
 -#}
 {% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+{% import g.theme.jinja_macros as theme_macros with context %}
 {% set n = c.project.neighborhood %}
 {% if not c.project or (n.neighborhood_project == c.project and not n.show_title) %}
   <div id="nav_menu_missing"></div>
 {% else %}
+  {{ theme_macros.breadcrumbs(c.project, c.app) }}
   {% if c.project.neighborhood.icon %}
     <a href="{{c.project.neighborhood.url()}}"><img src="{{c.project.neighborhood.url()}}/icon" class="neighborhood_icon"
        alt="Return to {{c.project.neighborhood.name}}" title="Return to {{c.project.neighborhood.name}}"></a>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6fe00297/Allura/allura/templates/jinja_master/theme_macros.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/theme_macros.html b/Allura/allura/templates/jinja_master/theme_macros.html
index e1c9903..a493075 100644
--- a/Allura/allura/templates/jinja_master/theme_macros.html
+++ b/Allura/allura/templates/jinja_master/theme_macros.html
@@ -78,3 +78,21 @@
 {%- macro extra_header(path_to_static) %}
 
 {%- endmacro %}
+
+{%- macro breadcrumbs(project, app) %}
+    <nav id="breadcrumbs">
+        <ul>
+            <li><a href="/">Home</a></li>
+            {% for label,url in project.breadcrumbs() %}
+                {% if not loop.last or app %}
+                    <li><a href="{{ url }}">{{ label }}</a></li>
+                {% else %}
+                    <li>{{ label }}</li>
+                {% endif %}
+            {% endfor %}
+            {% if app %}
+                <li>{{ app.config.options.mount_label }}</li>
+            {% endif %}
+        </ul>
+    </nav>
+{%- endmacro %}


[16/24] git commit: [#5716] show "Saved" message after saving main project info

Posted by jo...@apache.org.
[#5716] show "Saved" message after saving main project info


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

Branch: refs/heads/cj/6218
Commit: 8fc71796c30c5807d64987d00be6eda58376db15
Parents: 06d4a2a
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue May 28 21:58:14 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed May 29 19:01:56 2013 +0000

----------------------------------------------------------------------
 Allura/allura/ext/admin/admin_main.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8fc71796/Allura/allura/ext/admin/admin_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index 6f6dcea..7b188c9 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -392,6 +392,7 @@ class ProjectAdminController(BaseController):
                 square=True, thumbnail_size=(48,48),
                 thumbnail_meta=dict(project_id=c.project._id,category='icon'))
         g.post_event('project_updated')
+        flash('Saved', 'success')
         redirect('overview')
 
     def _add_trove(self, type, new_trove):