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/08/23 18:58:01 UTC
[01/50] git commit: [#3154] ticket:394 Bulk export: ForgeLink
Updated Branches:
refs/heads/cj/6530 c75da0b48 -> c6ffac86b (forced update)
[#3154] ticket:394 Bulk export: ForgeLink
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/aeaaa111
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/aeaaa111
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/aeaaa111
Branch: refs/heads/cj/6530
Commit: aeaaa111074ea83dc6ec2af441f416288d41c298
Parents: cde71c3
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Mon Jul 22 16:47:33 2013 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:40 2013 +0000
----------------------------------------------------------------------
ForgeLink/forgelink/link_main.py | 5 ++++
ForgeLink/forgelink/tests/test_app.py | 39 ++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aeaaa111/ForgeLink/forgelink/link_main.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index be8c918..2350e84 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -49,6 +49,7 @@ class ForgeLinkApp(Application):
ConfigOption('url', str, None)
]
searchable=True
+ exportable=True
tool_label='External Link'
default_mount_label='Link name'
default_mount_point='link'
@@ -93,6 +94,10 @@ class ForgeLinkApp(Application):
"Remove all the tool's artifacts from the database"
super(ForgeLinkApp, self).uninstall(project)
+ def bulk_export(self, f):
+ f.write('{"url": "%s"}' % self.config.options.get('url', 'test'))
+
+
class RootController(BaseController):
def _check_security(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aeaaa111/ForgeLink/forgelink/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/tests/test_app.py b/ForgeLink/forgelink/tests/test_app.py
new file mode 100644
index 0000000..2176b10
--- /dev/null
+++ b/ForgeLink/forgelink/tests/test_app.py
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import tempfile
+import json
+
+from allura.tests import decorators as td
+from allura import model as M
+from alluratest.controller import setup_basic_test
+
+
+class TestBulkExport(object):
+
+ def setUp(self):
+ setup_basic_test()
+
+ @td.with_link
+ def test_bulk_export(self):
+ self.project = M.Project.query.get(shortname='test')
+ self.link = self.project.app_instance('link')
+ self.link.config.options['url'] = 'http://sf.net'
+ f = tempfile.TemporaryFile()
+ self.link.bulk_export(f)
+ f.seek(0)
+ assert json.loads(f.read())['url']=='http://sf.net'
\ No newline at end of file
[30/50] git commit: [#3154] ticket:408 clean up export tests
Posted by jo...@apache.org.
[#3154] ticket:408 clean up export tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/cfb95aed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/cfb95aed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/cfb95aed
Branch: refs/heads/cj/6530
Commit: cfb95aedc82d1e4c02066044a64784dbcb582276
Parents: 8072d30
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Fri Aug 9 17:12:09 2013 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:44 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 2 +-
Allura/allura/tests/functional/test_admin.py | 25 +++++++++++++++--------
2 files changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cfb95aed/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 ca55645..0dbc5a5 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -108,7 +108,7 @@ class AdminApp(Application):
cls = AdminApp
tools = []
if cls._exportable_tools is None:
- for tool in project.ordered_mounts():
+ for tool in project.ordered_mounts(include_hidden=True):
if not tool.get('ac'):
continue
if project.app_instance(tool['ac']).exportable:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cfb95aed/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index d3a5bd9..6d17263 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -776,8 +776,7 @@ class TestExport(TestController):
self.setup_with_tools()
@td.with_wiki
- @td.with_tool('test', 'Tickets', 'bugs', 'Bugs')
- @td.with_tool('test', 'ShortUrl', 'urls', 'Urls')
+ @td.with_tool('test', 'Wiki', 'wiki2', 'Wiki2')
def setup_with_tools(self):
pass
@@ -785,7 +784,7 @@ class TestExport(TestController):
project = M.Project.query.get(shortname='test')
tools = [t.options.mount_point
for t in AdminApp.exportable_tools_for(project)]
- assert_equals(tools, [u'wiki', u'bugs'])
+ assert_equals(tools, [u'wiki', u'wiki2'])
def test_access(self):
r = self.app.get('/admin/export',
@@ -804,15 +803,22 @@ class TestExport(TestController):
def test_export_page_contains_exportable_tools(self):
r = self.app.get('/admin/export')
assert_in('Wiki</label> <a href="/p/test/wiki/">/p/test/wiki/</a>', r)
- assert_in('Bugs</label> <a href="/p/test/bugs/">/p/test/bugs/</a>', r)
- assert_not_in('Urls</label> <a href="/p/test/urls/">/p/test/urls/</a>', r)
+ assert_in('Wiki2</label> <a href="/p/test/wiki2/">/p/test/wiki2/</a>', r)
+ assert_not_in('Search</label> <a href="/p/test/search/">/p/test/search/</a>', r)
+
+ @patch('allura.ext.search.search_main.SearchApp.exportable')
+ def test_export_page_contains_hidden_tools(self, search_app):
+ project = M.Project.query.get(shortname='test')
+ tools = [t.options.mount_point
+ for t in AdminApp.exportable_tools_for(project)]
+ assert_equals(tools, [u'search', u'wiki', u'wiki2'])
def test_tools_not_selected(self):
r = self.app.post('/admin/export')
assert_in('error', self.webflash(r))
def test_bad_tool(self):
- r = self.app.post('/admin/export', {'tools': u'urls'})
+ r = self.app.post('/admin/export', {'tools': u'search'})
assert_in('error', self.webflash(r))
@mock.patch('allura.ext.admin.admin_main.export_tasks')
@@ -824,10 +830,10 @@ class TestExport(TestController):
@mock.patch('allura.ext.admin.admin_main.export_tasks')
def test_selected_multiple_tools(self, export_tasks):
- r = self.app.post('/admin/export', {'tools': [u'wiki', u'bugs']})
+ r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
assert_in('ok', self.webflash(r))
export_tasks.bulk_export.post.assert_called_once_with(
- 'test', [u'wiki', u'bugs'], u'test-admin')
+ 'test', [u'wiki', u'wiki2'], u'test-admin')
@patch('allura.ext.admin.admin_main.export_tasks')
def test_export_in_progress(self, export_tasks):
@@ -835,7 +841,8 @@ class TestExport(TestController):
tmpdir = os.path.join(p.bulk_export_path(), p.shortname)
shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
os.makedirs(tmpdir)
- r = self.app.post('/admin/export', {'tools': [u'wiki', u'bugs']})
+ r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
+ r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
assert_in('info', self.webflash(r))
assert_equals(export_tasks.bulk_export.post.call_count, 0)
shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
[21/50] git commit: [#3154] ticket:395 added project metadata to bulk
export task
Posted by jo...@apache.org.
[#3154] ticket:395 added project metadata to bulk export task
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/154814e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/154814e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/154814e7
Branch: refs/heads/cj/6530
Commit: 154814e782a36f451844eeeb92a7be145cec7064
Parents: 4100da6
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Thu Jul 25 13:46:28 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:43 2013 +0000
----------------------------------------------------------------------
Allura/allura/tasks/export_tasks.py | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/154814e7/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 9001500..395970c 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
+import json
import os
import logging
import shutil
@@ -64,6 +65,13 @@ def bulk_export(project_shortname, tools, username):
continue
try:
+ path = create_export_dir(project)
+ with open(os.path.join(path, 'project.json'), 'w') as f:
+ json.dump(project, f, cls=tg.jsonify.GenericJSON)
+ except:
+ log.error('Something went wrong during export of project metadata', exc_info=True)
+
+ try:
zip_and_cleanup(project)
except:
log.error('Something went wrong during zipping exported data.', exc_info=True)
[45/50] git commit: [#3154] few minor fixes
Posted by jo...@apache.org.
[#3154] few minor fixes
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/7a5bf4c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7a5bf4c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7a5bf4c7
Branch: refs/heads/cj/6530
Commit: 7a5bf4c7fba5c573e7d201f5de25172e6c9332d3
Parents: 719f6e9
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Aug 21 21:19:04 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:49:29 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/project.py | 2 +-
Allura/allura/tasks/export_tasks.py | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7a5bf4c7/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index f57dc34..ebccb3d 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -887,7 +887,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
export_task = MonQTask.query.get(**q)
if not export_task:
return
- if export_task.state in ('busy', 'ready'):
+ else:
return 'busy'
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7a5bf4c7/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index ee07057..06590021 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -77,7 +77,7 @@ def _bulk_export(project, tools, user):
zip_and_cleanup(project, export_filename)
else:
log.error('Nothing to export')
- None
+ return None
if not user:
log.info('No user. Skipping notification.')
@@ -115,8 +115,8 @@ def create_export_dir(project, export_filename):
def zip_and_cleanup(project, export_filename):
"""
- Zip exported data. Copy it to proper location. Remove temporary files.
- Returns base filename of zip file
+ Zip exported data for a given project and filename (no path).
+ Copy it to proper location. Remove temporary files.
"""
path = project.bulk_export_path()
temp = os.path.join(path, export_filename.split('.')[0])
[16/50] git commit: [#3154] ticket:393 Bulk export: ForgeBlog
Posted by jo...@apache.org.
[#3154] ticket:393 Bulk export: ForgeBlog
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b2ae1d0d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b2ae1d0d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b2ae1d0d
Branch: refs/heads/cj/6530
Commit: b2ae1d0d87c4114cd6d95dcd19f35b5c15644c38
Parents: c618a01
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Tue Jul 23 19:36:06 2013 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:42 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/test_tasks.py | 9 +++--
ForgeBlog/forgeblog/main.py | 16 +++++++-
ForgeBlog/forgeblog/tests/test_app.py | 62 ++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b2ae1d0d/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 654ed37..60a1abc 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -354,10 +354,13 @@ class TestExportTasks(unittest.TestCase):
mock.call('Can not load app for blog mount point. Skipping.')])
@mock.patch('allura.tasks.export_tasks.log')
- @td.with_tool('test', 'ShortUrl', 'urls')
+ @mock.patch('allura.tasks.export_tasks.M.Project.app_instance')
+ @mock.patch('allura.tasks.export_tasks.mail_tasks')
+ @td.with_tool('test', 'Tickets', 'bugs')
@td.with_tool('test', 'Blog', 'blog')
- def test_bulk_export_not_exportable_tool(self, log):
- export_tasks.bulk_export('test', [u'urls', u'blog'], 'test-admin')
+ def test_bulk_export_not_exportable_tool(self, mail_tasks, app, log):
+ app.return_value.exportable = False
+ export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin')
assert_equal(log.info.call_count, 2)
assert_equal(log.info.call_args_list, [
mock.call('Tool urls is not exportable. Skipping.'),
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b2ae1d0d/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 8bc56c0..afcc076 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -19,10 +19,11 @@
import logging
from datetime import datetime
import urllib2
+import json
# Non-stdlib imports
import pymongo
-from tg import config, expose, validate, redirect, flash
+from tg import config, expose, validate, redirect, flash, jsonify
from tg.decorators import with_trailing_slash, without_trailing_slash
from pylons import tmpl_context as c, app_globals as g
from pylons import request, response
@@ -90,6 +91,7 @@ class ForgeBlogApp(Application):
}
ordinal=14
installable=True
+ exportable = True
config_options = Application.config_options
default_external_feeds = []
icons={
@@ -188,6 +190,16 @@ class ForgeBlogApp(Application):
BM.BlogPostSnapshot.query.remove(dict(app_config_id=c.app.config._id))
super(ForgeBlogApp, self).uninstall(project)
+ def bulk_export(self, f):
+ f.write('{"posts": [')
+ posts = BM.BlogPost.query.find(dict(app_config_id=self.config._id)).sort('timestamp', pymongo.DESCENDING)
+ count = len(posts)
+ for i, post in enumerate(posts):
+ json.dump(post, f, cls=jsonify.GenericJSON)
+ if i < (count - 1):
+ f.write(',')
+ f.write(']}')
+
class RootController(BaseController, FeedController):
def __init__(self):
@@ -507,4 +519,4 @@ class PostRestController(BaseController):
if 'labels' in post_data:
self.post.labels = post_data['labels'].split(',')
self.post.commit()
- return self.post.__json__()
\ No newline at end of file
+ return self.post.__json__()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b2ae1d0d/ForgeBlog/forgeblog/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/test_app.py b/ForgeBlog/forgeblog/tests/test_app.py
new file mode 100644
index 0000000..7929dab
--- /dev/null
+++ b/ForgeBlog/forgeblog/tests/test_app.py
@@ -0,0 +1,62 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#-*- python -*-
+
+import tempfile
+import json
+from nose.tools import assert_equal
+
+from allura import model as M
+from allura.lib import helpers as h
+from alluratest.controller import setup_basic_test, setup_global_objects
+from allura.tests import decorators as td
+from forgeblog import model as BM
+
+
+class TestBulkExport(object):
+
+ def setUp(self):
+ setup_basic_test()
+ setup_global_objects()
+
+ @td.with_tool('test', 'Blog', 'blog')
+ def test_bulk_export(self):
+ project = M.Project.query.get(shortname='test')
+ blog = project.app_instance('blog')
+ h.set_context('test', 'blog', neighborhood='Projects')
+ post = BM.BlogPost()
+ post.title = 'Test title'
+ post.text = 'test post'
+ post.labels = ['the firstlabel', 'the second label']
+ post.make_slug()
+ post.discussion_thread.add_post(text='test comment')
+ post2 = BM.BlogPost()
+ post2.title = 'Test2 title'
+ post2.text = 'test2 post'
+ post2.make_slug()
+
+ f = tempfile.TemporaryFile()
+ blog.bulk_export(f)
+ f.seek(0)
+ blog = json.loads(f.read())
+ assert_equal(blog['posts'][0]['title'], 'Test2 title')
+ assert_equal(blog['posts'][0]['text'], 'test2 post')
+ assert_equal(blog['posts'][1]['title'], 'Test title')
+ assert_equal(blog['posts'][1]['text'], 'test post')
+ assert_equal(blog['posts'][1]['labels'], ['the firstlabel', 'the second label'])
+ assert_equal(blog['posts'][1]['discussion_thread']['posts'][0]['text'], 'test comment')
[18/50] git commit: [#3154] ticket:389 Remove trailing spaces and
commented code
Posted by jo...@apache.org.
[#3154] ticket:389 Remove trailing spaces and commented code
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c618a01b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c618a01b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c618a01b
Branch: refs/heads/cj/6530
Commit: c618a01b2f457dd75d9dc69b604f26668f6e521e
Parents: 2a60f9a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Jul 24 11:01:10 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:42 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/project.py | 2 --
ForgeTracker/forgetracker/tests/test_app.py | 4 ++--
ForgeTracker/forgetracker/tracker_main.py | 2 +-
3 files changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c618a01b/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index b6d6a1f..02fddac 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -911,8 +911,6 @@ class AppConfig(MappedClass):
tool_name=self.tool_name,
version=self.version,
options=self.options,
- # project=self.project,
- # discussion=self.discussion
tool_data=self.tool_data,
acl=self.acl,
)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c618a01b/ForgeTracker/forgetracker/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
index c84fa8d..0568829 100644
--- a/ForgeTracker/forgetracker/tests/test_app.py
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -48,11 +48,11 @@ class TestBulkExport(TrackerTestController):
tickets = sorted(tracker['tickets'], key=operator.itemgetter('summary'))
assert_equal(len(tickets), 2)
ticket_foo = tickets[1]
- assert_equal(ticket_foo['summary'], 'foo')
+ assert_equal(ticket_foo['summary'], 'foo')
assert_equal(ticket_foo['custom_fields']['_milestone'], '1.0')
posts_foo = ticket_foo['discussion_thread']['posts']
assert_equal(len(posts_foo), 1)
- assert_equal(posts_foo[0]['text'], 'silly comment')
+ assert_equal(posts_foo[0]['text'], 'silly comment')
tracker_config = tracker['tracker_config']
assert_equal(tracker_config['project_id'], unicode(self.project._id))
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c618a01b/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index a0740a9..d6d20db 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -424,7 +424,7 @@ class ForgeTrackerApp(Application):
milestones = self.milestones
json.dump(milestones, f, cls=jsonify.GenericJSON)
f.write(', "saved_bins":')
- bins = self.bins
+ bins = self.bins
json.dump(bins, f, cls=jsonify.GenericJSON)
f.write('}')
[07/50] git commit: [#3153] ticket:389 fixed tests for export
Posted by jo...@apache.org.
[#3153] ticket:389 fixed tests for export
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/68077e91
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/68077e91
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/68077e91
Branch: refs/heads/cj/6530
Commit: 68077e91d63b559d38976e5280e4240e230d86e1
Parents: d5e1ff1
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Jul 23 19:17:07 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:41 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/functional/test_admin.py | 16 ++++++++--------
Allura/allura/tests/test_tasks.py | 6 +++---
2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/68077e91/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 774fd36..d3a5bd9 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -776,8 +776,8 @@ class TestExport(TestController):
self.setup_with_tools()
@td.with_wiki
- @td.with_tool('test', 'Wiki', 'wiki2', 'Wiki 2')
@td.with_tool('test', 'Tickets', 'bugs', 'Bugs')
+ @td.with_tool('test', 'ShortUrl', 'urls', 'Urls')
def setup_with_tools(self):
pass
@@ -785,7 +785,7 @@ class TestExport(TestController):
project = M.Project.query.get(shortname='test')
tools = [t.options.mount_point
for t in AdminApp.exportable_tools_for(project)]
- assert_equals(tools, [u'wiki', u'wiki2'])
+ assert_equals(tools, [u'wiki', u'bugs'])
def test_access(self):
r = self.app.get('/admin/export',
@@ -804,15 +804,15 @@ class TestExport(TestController):
def test_export_page_contains_exportable_tools(self):
r = self.app.get('/admin/export')
assert_in('Wiki</label> <a href="/p/test/wiki/">/p/test/wiki/</a>', r)
- assert_in('Wiki 2</label> <a href="/p/test/wiki2/">/p/test/wiki2/</a>', r)
- assert_not_in('Bugs</label> <a href="/p/test/bugs/">/p/test/bugs/</a>', r)
+ assert_in('Bugs</label> <a href="/p/test/bugs/">/p/test/bugs/</a>', r)
+ assert_not_in('Urls</label> <a href="/p/test/urls/">/p/test/urls/</a>', r)
def test_tools_not_selected(self):
r = self.app.post('/admin/export')
assert_in('error', self.webflash(r))
def test_bad_tool(self):
- r = self.app.post('/admin/export', {'tools': u'bugs'})
+ r = self.app.post('/admin/export', {'tools': u'urls'})
assert_in('error', self.webflash(r))
@mock.patch('allura.ext.admin.admin_main.export_tasks')
@@ -824,10 +824,10 @@ class TestExport(TestController):
@mock.patch('allura.ext.admin.admin_main.export_tasks')
def test_selected_multiple_tools(self, export_tasks):
- r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
+ r = self.app.post('/admin/export', {'tools': [u'wiki', u'bugs']})
assert_in('ok', self.webflash(r))
export_tasks.bulk_export.post.assert_called_once_with(
- 'test', [u'wiki', u'wiki2'], u'test-admin')
+ 'test', [u'wiki', u'bugs'], u'test-admin')
@patch('allura.ext.admin.admin_main.export_tasks')
def test_export_in_progress(self, export_tasks):
@@ -835,7 +835,7 @@ class TestExport(TestController):
tmpdir = os.path.join(p.bulk_export_path(), p.shortname)
shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
os.makedirs(tmpdir)
- r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
+ r = self.app.post('/admin/export', {'tools': [u'wiki', u'bugs']})
assert_in('info', self.webflash(r))
assert_equals(export_tasks.bulk_export.post.call_count, 0)
shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/68077e91/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 39c3397..654ed37 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -354,13 +354,13 @@ class TestExportTasks(unittest.TestCase):
mock.call('Can not load app for blog mount point. Skipping.')])
@mock.patch('allura.tasks.export_tasks.log')
- @td.with_tool('test', 'Tickets', 'bugs')
+ @td.with_tool('test', 'ShortUrl', 'urls')
@td.with_tool('test', 'Blog', 'blog')
def test_bulk_export_not_exportable_tool(self, log):
- export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin')
+ export_tasks.bulk_export('test', [u'urls', u'blog'], 'test-admin')
assert_equal(log.info.call_count, 2)
assert_equal(log.info.call_args_list, [
- mock.call('Tool bugs is not exportable. Skipping.'),
+ mock.call('Tool urls is not exportable. Skipping.'),
mock.call('Tool blog is not exportable. Skipping.')])
@mock.patch('allura.tasks.export_tasks.shutil')
[42/50] git commit: [#3154] revise commit 099b2c so project metadata
is on AdminApp and less special handling is needed
Posted by jo...@apache.org.
[#3154] revise commit 099b2c so project metadata is on AdminApp and less special handling is needed
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/587f2d35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/587f2d35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/587f2d35
Branch: refs/heads/cj/6530
Commit: 587f2d358d15ca64b826b24e016220afbfa8e9e6
Parents: e564195
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Aug 16 21:20:26 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:46 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 25 +++++++++++-----------
Allura/allura/ext/admin/templates/export.html | 5 -----
Allura/allura/model/project.py | 6 +-----
Allura/allura/tasks/export_tasks.py | 24 +++++++++------------
Allura/allura/tests/functional/test_admin.py | 13 ++++-------
5 files changed, 27 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/587f2d35/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 f763258..cbb1e2c 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -19,12 +19,13 @@ import logging
from collections import defaultdict
from datetime import datetime
from urlparse import urlparse
+import json
import pkg_resources
from pylons import tmpl_context as c, app_globals as g
from pylons import request
from paste.deploy.converters import asbool
-from tg import expose, redirect, flash, validate, config
+from tg import expose, redirect, flash, validate, config, jsonify
from tg.decorators import with_trailing_slash, without_trailing_slash
from webob import exc
from bson import ObjectId
@@ -74,13 +75,13 @@ class AdminApp(Application):
__version__ = version.__version__
installable=False
_installable_tools = None
- _exportable_tools = None
tool_label = 'admin'
icons={
24:'images/admin_24.png',
32:'images/admin_32.png',
48:'images/admin_48.png'
}
+ exportable = True
def __init__(self, project, config):
Application.__init__(self, project, config)
@@ -105,15 +106,11 @@ class AdminApp(Application):
@staticmethod
def exportable_tools_for(project):
- cls = AdminApp
- tools = [project]
- if cls._exportable_tools is None:
- for tool in project.ordered_mounts(include_hidden=True):
- if not tool.get('ac'):
- continue
- if project.app_instance(tool['ac']).exportable:
- tools.append(tool['ac'])
- return tools
+ tools = []
+ for tool in project.app_configs:
+ if project.app_instance(tool).exportable:
+ tools.append(tool)
+ return sorted(tools, key=lambda t: t.options.mount_point)
def main_menu(self):
'''Apps should provide their entries to be added to the main nav
@@ -168,6 +165,9 @@ class AdminApp(Application):
def install(self, project):
pass
+ def bulk_export(self, f):
+ json.dump(self.project, f, cls=jsonify.GenericJSON, indent=2)
+
class AdminExtensionLookup(object):
@@ -645,8 +645,7 @@ class ProjectAdminController(BaseController):
redirect('export')
if isinstance(tools, basestring):
tools = [tools]
- allowed = set(t.options.mount_point for t in exportable_tools if hasattr(t, 'options'))
- allowed.add('project')
+ allowed = set(t.options.mount_point for t in exportable_tools)
if not set(tools).issubset(allowed):
flash('Wrong tools in input data', 'error')
redirect('export')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/587f2d35/Allura/allura/ext/admin/templates/export.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/export.html b/Allura/allura/ext/admin/templates/export.html
index 6287be7..eff9d5a 100644
--- a/Allura/allura/ext/admin/templates/export.html
+++ b/Allura/allura/ext/admin/templates/export.html
@@ -38,13 +38,8 @@
<form method="POST" action="">
{% for tool in tools %}
<div class="grid-19">
- {% if tool.name %}
- <input type="checkbox" name="tools" id="tool-{{ loop.index }}" value="project">
- <label for="tool-{{ loop.index }}">{{ tool.name }}</label> <a href="{{ tool.url() }}">{{ tool.url() }}</a>
- {% else %}
<input type="checkbox" name="tools" id="tool-{{ loop.index }}" value="{{ tool.options.mount_point }}">
<label for="tool-{{ loop.index }}">{{ tool.options.mount_label }}</label> <a href="{{ tool.url() }}">{{ tool.url() }}</a>
- {% endif %}
</div>
{% endfor %}
<p><div class="grid-19"><input type="submit" value="Export"></div></p>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/587f2d35/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 021bb47..95ad80f 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -17,13 +17,12 @@
import os
import logging
-import json
from collections import Counter, OrderedDict
from datetime import datetime
from copy import deepcopy
import urllib
-from tg import config, jsonify
+from tg import config
from pylons import tmpl_context as c, app_globals as g
from pylons import request
from paste.deploy.converters import asbool
@@ -877,9 +876,6 @@ class Project(MappedClass, ActivityNode, ActivityObject):
elif os.path.exists(tmpdir):
return 'busy'
- def bulk_export(self, f):
- json.dump(self, f, cls=jsonify.GenericJSON, indent=2)
-
def __json__(self):
return dict(
shortname=self.shortname,
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/587f2d35/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 4b30c36..b6a84ac 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -46,26 +46,22 @@ def bulk_export(project_shortname, tools, username, neighborhood):
return
not_exported_tools = []
for tool in tools or []:
- entry_to_export = None
- if tool == 'project':
- entry_to_export = project
- else:
- entry_to_export = project.app_instance(tool)
- if not entry_to_export:
- log.info('Can not load app for %s mount point. Skipping.' % tool)
- not_exported_tools.append(tool)
- continue
- if not entry_to_export.exportable:
- log.info('Tool %s is not exportable. Skipping.' % tool)
- not_exported_tools.append(tool)
- continue
+ app = project.app_instance(tool)
+ if not app:
+ log.info('Can not load app for %s mount point. Skipping.' % tool)
+ not_exported_tools.append(tool)
+ continue
+ if not app.exportable:
+ log.info('Tool %s is not exportable. Skipping.' % tool)
+ not_exported_tools.append(tool)
+ continue
log.info('Exporting %s...' % tool)
try:
path = create_export_dir(project)
temp_name = mkstemp(dir=path)[1]
with open(temp_name, 'w') as f:
with h.push_context(project._id):
- entry_to_export.bulk_export(f)
+ app.bulk_export(f)
os.rename(temp_name, os.path.join(path, '%s.json' % tool))
except:
log.error('Something went wrong during export of %s' % tool, exc_info=True)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/587f2d35/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 4988a8c..669f113 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -784,11 +784,8 @@ class TestExport(TestController):
def test_exportable_tools_for(self):
project = M.Project.query.get(shortname='test')
exportable_tools = AdminApp.exportable_tools_for(project)
- tools = [t.options.mount_point
- for t in AdminApp.exportable_tools_for(project)
- if hasattr(t, 'options')]
- assert_equals(tools, [u'wiki', u'wiki2'])
- assert_in(project, exportable_tools)
+ exportable_mount_points = [t.options.mount_point for t in exportable_tools]
+ assert_equals(exportable_mount_points, [u'admin', u'wiki', u'wiki2'])
def test_access(self):
r = self.app.get('/admin/export',
@@ -824,10 +821,8 @@ class TestExport(TestController):
with mock.patch('allura.ext.search.search_main.SearchApp.exportable'):
project = M.Project.query.get(shortname='test')
exportable_tools = AdminApp.exportable_tools_for(project)
- tools = [t.options.mount_point for t in exportable_tools
- if hasattr(t, 'options')]
- assert_equals(tools, [u'search', u'wiki', u'wiki2'])
- assert_in(project, exportable_tools)
+ exportable_mount_points = [t.options.mount_point for t in exportable_tools]
+ assert_equals(exportable_mount_points, [u'admin', u'search', u'wiki', u'wiki2'])
def test_tools_not_selected(self):
r = self.app.post('/admin/export')
[26/50] git commit: [#3154] pretty JSON output in exports
Posted by jo...@apache.org.
[#3154] pretty JSON output in exports
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/9d6fda88
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9d6fda88
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9d6fda88
Branch: refs/heads/cj/6530
Commit: 9d6fda88067c7912f7fee2c307db4e16fadc9592
Parents: 9cbb599
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Aug 1 19:24:48 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:43 2013 +0000
----------------------------------------------------------------------
Allura/allura/tasks/export_tasks.py | 2 +-
ForgeBlog/forgeblog/main.py | 2 +-
ForgeDiscussion/forgediscussion/forum_main.py | 2 +-
ForgeLink/forgelink/link_main.py | 2 +-
ForgeTracker/forgetracker/tracker_main.py | 14 +++++++-------
ForgeWiki/forgewiki/wiki_main.py | 2 +-
6 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d6fda88/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 395970c..9933e26 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -67,7 +67,7 @@ def bulk_export(project_shortname, tools, username):
try:
path = create_export_dir(project)
with open(os.path.join(path, 'project.json'), 'w') as f:
- json.dump(project, f, cls=tg.jsonify.GenericJSON)
+ json.dump(project, f, cls=tg.jsonify.GenericJSON, indent=2)
except:
log.error('Something went wrong during export of project metadata', exc_info=True)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d6fda88/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index afcc076..e6da34f 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -195,7 +195,7 @@ class ForgeBlogApp(Application):
posts = BM.BlogPost.query.find(dict(app_config_id=self.config._id)).sort('timestamp', pymongo.DESCENDING)
count = len(posts)
for i, post in enumerate(posts):
- json.dump(post, f, cls=jsonify.GenericJSON)
+ json.dump(post, f, cls=jsonify.GenericJSON, indent=2)
if i < (count - 1):
f.write(',')
f.write(']}')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d6fda88/ForgeDiscussion/forgediscussion/forum_main.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index 2465312..bf1835d 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -222,7 +222,7 @@ class ForgeDiscussionApp(Application):
forums = DM.Forum.query.find(dict(app_config_id=self.config._id)).sort('mod_date', pymongo.DESCENDING).all()
count = len(forums)
for i, forum in enumerate(forums):
- json.dump(forum, f, cls=jsonify.GenericJSON)
+ json.dump(forum, f, cls=jsonify.GenericJSON, indent=2)
if i < (count - 1):
f.write(',')
f.write(']}')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d6fda88/ForgeLink/forgelink/link_main.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index b5dd0d4..199304a 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -96,7 +96,7 @@ class ForgeLinkApp(Application):
super(ForgeLinkApp, self).uninstall(project)
def bulk_export(self, f):
- json.dump(RootRestController().link_json(), f, cls=jsonify.GenericJSON)
+ json.dump(RootRestController().link_json(), f, cls=jsonify.GenericJSON, indent=2)
class RootController(BaseController):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d6fda88/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index d6d20db..4ee0e74 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -415,17 +415,17 @@ class ForgeTrackerApp(Application):
deleted=False)).all()
count = len(tickets)
for i, ticket in enumerate(tickets):
- json.dump(ticket, f, cls=jsonify.GenericJSON)
+ json.dump(ticket, f, cls=jsonify.GenericJSON, indent=2)
if i < (count - 1):
f.write(',')
- f.write('], "tracker_config":')
- json.dump(self.config, f, cls=jsonify.GenericJSON)
- f.write(', "milestones":')
+ f.write('],\n"tracker_config":')
+ json.dump(self.config, f, cls=jsonify.GenericJSON, indent=2)
+ f.write(',\n"milestones":')
milestones = self.milestones
- json.dump(milestones, f, cls=jsonify.GenericJSON)
- f.write(', "saved_bins":')
+ json.dump(milestones, f, cls=jsonify.GenericJSON, indent=2)
+ f.write(',\n"saved_bins":')
bins = self.bins
- json.dump(bins, f, cls=jsonify.GenericJSON)
+ json.dump(bins, f, cls=jsonify.GenericJSON, indent=2)
f.write('}')
@property
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d6fda88/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index f27ff73..f0b85a7 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -294,7 +294,7 @@ The wiki uses [Markdown](%s) syntax.
deleted=False)).all()
count = len(pages)
for i, page in enumerate(pages):
- json.dump(page, f, cls=jsonify.GenericJSON)
+ json.dump(page, f, cls=jsonify.GenericJSON, indent=2)
if i < (count - 1):
f.write(',')
f.write(']}')
[13/50] git commit: [#3154] ticket:395 added more info to project json
Posted by jo...@apache.org.
[#3154] ticket:395 added more info to project 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/ca4437ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ca4437ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ca4437ad
Branch: refs/heads/cj/6530
Commit: ca4437addd2120991ba68fd2b64ce15db6c3a7e8
Parents: ef74610
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Wed Jul 24 17:21:11 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:42 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/auth.py | 7 +++++++
Allura/allura/model/project.py | 8 ++++++++
2 files changed, 15 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ca4437ad/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index da0b164..c8964f3 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -698,6 +698,13 @@ class User(MappedClass, ActivityNode, ActivityObject):
def withskill(cls, skill):
return cls.query.find({"skills.category_id" : skill._id})
+ def __json__(self):
+ return dict(
+ username=self.username,
+ name=self.display_name,
+ url=self.url(),
+ )
+
class OldProjectRole(MappedClass):
class __mongometa__:
session = project_orm_session
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ca4437ad/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 1525eec..941b360 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -840,6 +840,14 @@ class Project(MappedClass, ActivityNode, ActivityObject):
def __json__(self):
return dict(
name=self.shortname,
+ title=self.name,
+ _id=self._id,
+ private=self.private,
+ short_description=self.short_description,
+ description=self.description,
+ download_page=self.best_download_url(),
+ preferred_support=self.support_page_url,
+ developers=self.users_with_role('Developer'),
tools=[dict(name=t.tool_name, mount_point=t.options.mount_point, label=t.options.mount_label)
for t in self.app_configs if h.has_access(t, 'read')]
)
[35/50] git commit: ticket:411 bulk_export_enabled added to config
Posted by jo...@apache.org.
ticket:411 bulk_export_enabled added to config
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/90077d52
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/90077d52
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/90077d52
Branch: refs/heads/cj/6530
Commit: 90077d5245e55ff2afb4e56658d212090c350ecd
Parents: 68ed96e
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Aug 13 19:07:09 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:45 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/90077d52/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 d1f98da..6031625 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -142,7 +142,8 @@ class AdminApp(Application):
SitemapEntry('Categorization', admin_url+'trove')
]
links.append(SitemapEntry('Tools', admin_url+'tools'))
- links.append(SitemapEntry('Export', admin_url + 'export'))
+ if config.get('bulk_export_enabled', 'false') == 'true':
+ links.append(SitemapEntry('Export', admin_url + 'export'))
if c.project.is_root and has_access(c.project, 'admin')():
links.append(SitemapEntry('User Permissions', admin_url+'groups/'))
if not c.project.is_root and has_access(c.project, 'admin')():
@@ -635,6 +636,8 @@ class ProjectAdminController(BaseController):
@expose('jinja:allura.ext.admin:templates/export.html')
def export(self, tools=None):
+ if config.get('bulk_export_enabled', 'true') != 'true':
+ redirect('.')
exportable_tools = AdminApp.exportable_tools_for(c.project)
if request.method == 'POST':
if not tools:
[22/50] git commit: [#3154] ticket:395 added test for project api
Posted by jo...@apache.org.
[#3154] ticket:395 added test for project 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/4100da66
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4100da66
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4100da66
Branch: refs/heads/cj/6530
Commit: 4100da6651ed78290cb6af5016326f6c20a5f76e
Parents: ca4437a
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Thu Jul 25 12:46:11 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:43 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/functional/test_rest.py | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4100da66/Allura/allura/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_rest.py b/Allura/allura/tests/functional/test_rest.py
index d5ed769..0278666 100644
--- a/Allura/allura/tests/functional/test_rest.py
+++ b/Allura/allura/tests/functional/test_rest.py
@@ -72,9 +72,20 @@ class TestRestHome(TestRestApiBase):
r = self.api_get('/rest/p/test/')
assert r.status_int == 200
+ def test_project_data(self):
+ r = self.api_get('/rest/p/test/')
+ assert_equal(r.json['name'], 'test')
+ assert_equal(r.json['title'], 'Test Project')
+ assert_equal(r.json['description'], 'You can edit this description in the admin page')
+ assert_equal(len(r.json['developers']), 1)
+ admin_dev = r.json['developers'][0]
+ assert_equal(admin_dev['username'], 'test-admin')
+ assert_equal(admin_dev['name'], 'Test Admin')
+ assert_equal(admin_dev['url'], '/u/test-admin/')
+
@td.with_tool('test', 'Tickets', 'bugs')
@td.with_tool('test', 'Tickets', 'private-bugs')
- def test_project_data(self):
+ def test_project_data_tools(self):
# Deny anonymous to see 'private-bugs' tool
role = M.ProjectRole.by_name('*anonymous')._id
read_permission = M.ACE.allow(role, 'read')
[28/50] git commit: [#3154] fix blog export test
Posted by jo...@apache.org.
[#3154] fix blog export test
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/818b3956
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/818b3956
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/818b3956
Branch: refs/heads/cj/6530
Commit: 818b395614726235bcfcc0e7658e40e45e2bb391
Parents: 9d6fda8
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Aug 1 19:31:42 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:44 2013 +0000
----------------------------------------------------------------------
ForgeBlog/forgeblog/tests/test_app.py | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/818b3956/ForgeBlog/forgeblog/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/test_app.py b/ForgeBlog/forgeblog/tests/test_app.py
index 7929dab..622dccf 100644
--- a/ForgeBlog/forgeblog/tests/test_app.py
+++ b/ForgeBlog/forgeblog/tests/test_app.py
@@ -44,11 +44,13 @@ class TestBulkExport(object):
post.text = 'test post'
post.labels = ['the firstlabel', 'the second label']
post.make_slug()
+ post.commit()
post.discussion_thread.add_post(text='test comment')
post2 = BM.BlogPost()
post2.title = 'Test2 title'
post2.text = 'test2 post'
post2.make_slug()
+ post2.commit()
f = tempfile.TemporaryFile()
blog.bulk_export(f)
[03/50] git commit: [#3154] ticket:386 Notify user when export
finished
Posted by jo...@apache.org.
[#3154] ticket:386 Notify user when export finished
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/449d9e72
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/449d9e72
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/449d9e72
Branch: refs/heads/cj/6530
Commit: 449d9e72a6a99a3f9cb873f246eb1df8d2a522b9
Parents: 88bfef1
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Jul 4 17:28:24 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:40 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 2 +-
Allura/allura/tasks/export_tasks.py | 29 +++++++++++++++++++++-
Allura/allura/templates/mail/bulk_export.html | 29 ++++++++++++++++++++++
Allura/allura/tests/functional/test_admin.py | 15 ++++++++---
Allura/allura/tests/test_tasks.py | 21 ++++++++++++----
Allura/development.ini | 1 +
Allura/test.ini | 1 +
7 files changed, 87 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/449d9e72/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 ee59e1d..ca55645 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -649,7 +649,7 @@ class ProjectAdminController(BaseController):
if c.project.bulk_export_status() == 'busy':
flash('Export for project %s already running' % c.project.shortname, 'info')
redirect('export')
- export_tasks.bulk_export.post(c.project.shortname, tools)
+ export_tasks.bulk_export.post(c.project.shortname, tools, c.user.username)
flash('Export scheduled', 'ok')
redirect('export')
return {
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/449d9e72/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 64aee3f..d097205 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -19,8 +19,13 @@ import os
import logging
import shutil
+import tg
+from pylons import app_globals as g
+
from allura import model as M
+from allura.tasks import mail_tasks
from allura.lib.decorators import task
+from allura.lib import helpers as h
from allura.model.repository import zipdir
@@ -28,7 +33,7 @@ log = logging.getLogger(__name__)
@task
-def bulk_export(project_shortname, tools):
+def bulk_export(project_shortname, tools, username):
project = M.Project.query.get(shortname=project_shortname)
if not project:
log.error('Project %s not found' % project_shortname)
@@ -58,6 +63,28 @@ def bulk_export(project_shortname, tools):
except:
log.error('Something went wrong during zipping exported data.', exc_info=True)
+ user = M.User.by_username(username)
+ if not user:
+ log.info('Can not find user %s. Skipping notification.' % username)
+ return
+ tmpl = g.jinja2_env.get_template('allura:templates/mail/bulk_export.html')
+ instructions = tg.config.get('bulk_export_download_instructions', '')
+ instructions = instructions.format(project=project.shortname)
+ tmpl_context = {
+ 'instructions': instructions,
+ 'project': project,
+ 'tools': tools,
+ }
+ email = {
+ 'fromaddr': unicode(user.email_address_header()),
+ 'reply_to': unicode(user.email_address_header()),
+ 'message_id': h.gen_message_id(),
+ 'destinations': [unicode(user._id)],
+ 'subject': u'Bulk export for project %s completed' % project_shortname,
+ 'text': tmpl.render(tmpl_context),
+ }
+ mail_tasks.sendmail.post(**email)
+
def create_export_dir(project):
"""Create temporary directory for export files"""
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/449d9e72/Allura/allura/templates/mail/bulk_export.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/mail/bulk_export.html b/Allura/allura/templates/mail/bulk_export.html
new file mode 100644
index 0000000..420848f
--- /dev/null
+++ b/Allura/allura/templates/mail/bulk_export.html
@@ -0,0 +1,29 @@
+{#
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+#}
+
+Bulk export for project {{ project.shortname }} is completed.
+
+Following tools was exported:
+{% for tool in tools %}
+- {{ tool }}
+{% endfor %}
+
+Follow instructions below to get exported data.
+
+{{ instructions }}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/449d9e72/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 8e205b5..774fd36 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -820,26 +820,33 @@ class TestExport(TestController):
r = self.app.post('/admin/export', {'tools': u'wiki'})
assert_in('ok', self.webflash(r))
export_tasks.bulk_export.post.assert_called_once_with(
- 'test', [u'wiki'])
+ 'test', [u'wiki'], u'test-admin')
@mock.patch('allura.ext.admin.admin_main.export_tasks')
def test_selected_multiple_tools(self, export_tasks):
r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
assert_in('ok', self.webflash(r))
export_tasks.bulk_export.post.assert_called_once_with(
- 'test', [u'wiki', u'wiki2'])
+ 'test', [u'wiki', u'wiki2'], u'test-admin')
@patch('allura.ext.admin.admin_main.export_tasks')
def test_export_in_progress(self, export_tasks):
p = M.Project.query.get(shortname='test')
tmpdir = os.path.join(p.bulk_export_path(), p.shortname)
- shutil.rmtree(tmpdir, ignore_errors=True)
+ shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
os.makedirs(tmpdir)
r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
assert_in('info', self.webflash(r))
assert_equals(export_tasks.bulk_export.post.call_count, 0)
- shutil.rmtree(tmpdir, ignore_errors=True)
+ shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
def test_export_done(self):
+ p = M.Project.query.get(shortname='test')
+ shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
+ os.makedirs(p.bulk_export_path())
+ fn = os.path.join(p.bulk_export_path(), p.bulk_export_filename())
+ with open(fn, 'w') as f:
+ f.write('Pretending I am zip archive')
r = self.app.get('/admin/export')
assert_in('<h2>Careful!</h2>', r)
+ shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/449d9e72/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 5f2e44c..39c3397 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -342,12 +342,12 @@ class TestExportTasks(unittest.TestCase):
@mock.patch('allura.tasks.export_tasks.log')
def test_bulk_export_invalid_project(self, log):
- export_tasks.bulk_export('bad', [u'wiki'])
+ export_tasks.bulk_export('bad', [u'wiki'], 'test-admin')
log.error.assert_called_once_with('Project bad not found')
@mock.patch('allura.tasks.export_tasks.log')
def test_bulk_export_invalid_tool(self, log):
- export_tasks.bulk_export('test', [u'bugs', u'blog'])
+ export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin')
assert_equal(log.info.call_count, 2)
assert_equal(log.info.call_args_list, [
mock.call('Can not load app for bugs mount point. Skipping.'),
@@ -357,7 +357,7 @@ class TestExportTasks(unittest.TestCase):
@td.with_tool('test', 'Tickets', 'bugs')
@td.with_tool('test', 'Blog', 'blog')
def test_bulk_export_not_exportable_tool(self, log):
- export_tasks.bulk_export('test', [u'bugs', u'blog'])
+ export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin')
assert_equal(log.info.call_count, 2)
assert_equal(log.info.call_args_list, [
mock.call('Tool bugs is not exportable. Skipping.'),
@@ -369,7 +369,8 @@ class TestExportTasks(unittest.TestCase):
@mock.patch('allura.tasks.export_tasks.log')
@td.with_wiki
def test_bulk_export(self, log, wiki_bulk_export, zipdir, shutil):
- export_tasks.bulk_export('test', [u'wiki'])
+ M.MonQTask.query.remove()
+ export_tasks.bulk_export('test', [u'wiki'], 'test-admin')
assert_equal(log.info.call_count, 1)
assert_equal(log.info.call_args_list, [
mock.call('Exporting wiki...')])
@@ -379,6 +380,16 @@ class TestExportTasks(unittest.TestCase):
zipdir.assert_caled_once_with(temp, temp + '/test.zip')
shutil.move.assert_called_once_with(temp + '/test.zip', zipfn)
shutil.rmtree.assert_called_once_with(temp)
+ # check notification
+ M.MonQTask.run_ready()
+ tasks = M.MonQTask.query.find(
+ dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
+ assert_equal(len(tasks), 1)
+ assert_equal(tasks[0].kwargs['subject'], 'Bulk export for project test completed')
+ text = tasks[0].kwargs['text']
+ assert_in('Bulk export for project test is completed.', text)
+ assert_in('Following tools was exported:\n\n- wiki', text)
+ assert_in('Sample instructions for test', text)
@mock.patch('forgewiki.wiki_main.ForgeWikiApp.bulk_export')
@mock.patch('allura.tasks.export_tasks.log')
@@ -387,7 +398,7 @@ class TestExportTasks(unittest.TestCase):
project = M.Project.query.get(shortname='test')
export_tasks.create_export_dir(project)
assert_equal(project.bulk_export_status(), 'busy')
- export_tasks.bulk_export('test', [u'wiki'])
+ export_tasks.bulk_export('test', [u'wiki'], 'test-admin')
log.info.assert_called_once_with('Another export is running for project test. Skipping.')
assert_equal(wiki_bulk_export.call_count, 0)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/449d9e72/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 6fe2e6e..0d3386b 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -143,6 +143,7 @@ scm.repos.tarball.url_prefix = http://localhost/
scm.repos.tarball.zip_binary = /usr/bin/zip
bulk_export_path = /tmp/bulk_export/{nbhd}/{project}
+bulk_export_download_instructions = Sample instructions for {project}
# space-separated list of tool names that are valid options
# for project admins to set for their 'support_page' field
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/449d9e72/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index 6babfaf..9ce586e 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -103,6 +103,7 @@ scm.repos.tarball.root = /tmp/tarball
scm.repos.tarball.url_prefix = file://
bulk_export_path = /tmp/bulk_export/{nbhd}/{project}
+bulk_export_download_instructions = Sample instructions for {project}
support_tool_choices = wiki tickets discussion
[04/50] git commit: [#3154] ticket:386 Check export status in UI
Posted by jo...@apache.org.
[#3154] ticket:386 Check export status in UI
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/88bfef18
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/88bfef18
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/88bfef18
Branch: refs/heads/cj/6530
Commit: 88bfef18130b98482000697379f90484e531893e
Parents: 8e3dfa2
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Jul 4 16:00:36 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:40 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 8 +++++++-
Allura/allura/ext/admin/templates/export.html | 10 ++++++++++
Allura/allura/tests/functional/test_admin.py | 16 ++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88bfef18/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 6b39c35..ee59e1d 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -646,10 +646,16 @@ class ProjectAdminController(BaseController):
if not set(tools).issubset(allowed):
flash('Wrong tools in input data', 'error')
redirect('export')
+ if c.project.bulk_export_status() == 'busy':
+ flash('Export for project %s already running' % c.project.shortname, 'info')
+ redirect('export')
export_tasks.bulk_export.post(c.project.shortname, tools)
flash('Export scheduled', 'ok')
redirect('export')
- return {'tools': exportable_tools}
+ return {
+ 'tools': exportable_tools,
+ 'status': c.project.bulk_export_status()
+ }
class PermissionsController(BaseController):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88bfef18/Allura/allura/ext/admin/templates/export.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/export.html b/Allura/allura/ext/admin/templates/export.html
index 6b69fdc..eff9d5a 100644
--- a/Allura/allura/ext/admin/templates/export.html
+++ b/Allura/allura/ext/admin/templates/export.html
@@ -23,6 +23,16 @@
{% block header %}Project Export{% endblock %}
{% block content %}
+
+{% if status == 'ready' %}
+<div class="error">
+ <h2>Careful!</h2>
+ This project has been exported already.
+ Follow instructions in notification email to get the exported data.
+ If you run export again previous exported data will be lost.
+</div>
+{% endif %}
+
<div class="grid-19">
{% if tools %}
<form method="POST" action="">
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88bfef18/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index fd8d791..8e205b5 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -17,6 +17,7 @@
import re
import os, allura
+import shutil
import pkg_resources
import StringIO
from contextlib import contextmanager
@@ -827,3 +828,18 @@ class TestExport(TestController):
assert_in('ok', self.webflash(r))
export_tasks.bulk_export.post.assert_called_once_with(
'test', [u'wiki', u'wiki2'])
+
+ @patch('allura.ext.admin.admin_main.export_tasks')
+ def test_export_in_progress(self, export_tasks):
+ p = M.Project.query.get(shortname='test')
+ tmpdir = os.path.join(p.bulk_export_path(), p.shortname)
+ shutil.rmtree(tmpdir, ignore_errors=True)
+ os.makedirs(tmpdir)
+ r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
+ assert_in('info', self.webflash(r))
+ assert_equals(export_tasks.bulk_export.post.call_count, 0)
+ shutil.rmtree(tmpdir, ignore_errors=True)
+
+ def test_export_done(self):
+ r = self.app.get('/admin/export')
+ assert_in('<h2>Careful!</h2>', r)
[33/50] git commit: [#3154] ticket:411 removed try near
zip_and_cleanup
Posted by jo...@apache.org.
[#3154] ticket:411 removed try near zip_and_cleanup
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b2e246d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b2e246d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b2e246d7
Branch: refs/heads/cj/6530
Commit: b2e246d7ff6ab5e98049ef194fa87b724250f388
Parents: 1c24bb7
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Aug 13 15:51:39 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:44 2013 +0000
----------------------------------------------------------------------
Allura/allura/tasks/export_tasks.py | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b2e246d7/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 0eb99e0..3e2a9af 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -72,10 +72,9 @@ def bulk_export(project_shortname, tools, username, neighborhood):
except:
log.error('Something went wrong during export of project metadata', exc_info=True)
- try:
- zip_and_cleanup(project)
- except:
- log.error('Something went wrong during zipping exported data.', exc_info=True)
+ # If that fails, we need to let it fail
+ # there won't be a valid zip file for the user to get.
+ zip_and_cleanup(project)
user = M.User.by_username(username)
if not user:
[37/50] git commit: [#4154] ticket:411 project export refactoring
Posted by jo...@apache.org.
[#4154] ticket:411 project export refactoring
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e5bcf01a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e5bcf01a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e5bcf01a
Branch: refs/heads/cj/6530
Commit: e5bcf01ae82995aa365a8a1d0c9ac851c829f237
Parents: 50ff514
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Thu Aug 15 14:31:27 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:45 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 7 +++--
Allura/allura/ext/admin/templates/export.html | 5 ++++
Allura/allura/model/project.py | 6 +++-
Allura/allura/tasks/export_tasks.py | 33 ++++++++++------------
Allura/allura/tests/functional/test_admin.py | 10 +++++--
5 files changed, 37 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e5bcf01a/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 6031625..9cc0f28 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -106,7 +106,7 @@ class AdminApp(Application):
@staticmethod
def exportable_tools_for(project):
cls = AdminApp
- tools = []
+ tools = [project]
if cls._exportable_tools is None:
for tool in project.ordered_mounts(include_hidden=True):
if not tool.get('ac'):
@@ -142,7 +142,7 @@ class AdminApp(Application):
SitemapEntry('Categorization', admin_url+'trove')
]
links.append(SitemapEntry('Tools', admin_url+'tools'))
- if config.get('bulk_export_enabled', 'false') == 'true':
+ if config.get('bulk_export_enabled', 'true') == 'true':
links.append(SitemapEntry('Export', admin_url + 'export'))
if c.project.is_root and has_access(c.project, 'admin')():
links.append(SitemapEntry('User Permissions', admin_url+'groups/'))
@@ -645,7 +645,8 @@ class ProjectAdminController(BaseController):
redirect('export')
if isinstance(tools, basestring):
tools = [tools]
- allowed = set(t.options.mount_point for t in exportable_tools)
+ allowed = set(t.options.mount_point for t in exportable_tools if hasattr(t, 'options'))
+ allowed.add('project')
if not set(tools).issubset(allowed):
flash('Wrong tools in input data', 'error')
redirect('export')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e5bcf01a/Allura/allura/ext/admin/templates/export.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/export.html b/Allura/allura/ext/admin/templates/export.html
index eff9d5a..6287be7 100644
--- a/Allura/allura/ext/admin/templates/export.html
+++ b/Allura/allura/ext/admin/templates/export.html
@@ -38,8 +38,13 @@
<form method="POST" action="">
{% for tool in tools %}
<div class="grid-19">
+ {% if tool.name %}
+ <input type="checkbox" name="tools" id="tool-{{ loop.index }}" value="project">
+ <label for="tool-{{ loop.index }}">{{ tool.name }}</label> <a href="{{ tool.url() }}">{{ tool.url() }}</a>
+ {% else %}
<input type="checkbox" name="tools" id="tool-{{ loop.index }}" value="{{ tool.options.mount_point }}">
<label for="tool-{{ loop.index }}">{{ tool.options.mount_label }}</label> <a href="{{ tool.url() }}">{{ tool.url() }}</a>
+ {% endif %}
</div>
{% endfor %}
<p><div class="grid-19"><input type="submit" value="Export"></div></p>
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e5bcf01a/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 18bd934..41ea5c7 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -17,12 +17,13 @@
import os
import logging
+import json
from collections import Counter, OrderedDict
from datetime import datetime
from copy import deepcopy
import urllib
-from tg import config
+from tg import config, jsonify
from pylons import tmpl_context as c, app_globals as g
from pylons import request
from paste.deploy.converters import asbool
@@ -875,6 +876,9 @@ class Project(MappedClass, ActivityNode, ActivityObject):
elif os.path.exists(tmpdir):
return 'busy'
+ def bulk_export(self, f):
+ json.dump(self, f, cls=jsonify.GenericJSON, indent=2)
+
def __json__(self):
return dict(
shortname=self.shortname,
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e5bcf01a/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index b5fcb34..bbd4b1d 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -45,33 +45,30 @@ def bulk_export(project_shortname, tools, username, neighborhood):
return
not_exported_tools = []
for tool in tools or []:
- app = project.app_instance(tool)
- if not app:
- log.info('Can not load app for %s mount point. Skipping.' % tool)
- not_exported_tools.append(tool)
- continue
- if not app.exportable:
- log.info('Tool %s is not exportable. Skipping.' % tool)
- not_exported_tools.append(tool)
- continue
+ entry_to_export = None
+ if tool == 'project':
+ entry_to_export = project
+ else:
+ entry_to_export = project.app_instance(tool)
+ if not entry_to_export:
+ log.info('Can not load app for %s mount point. Skipping.' % tool)
+ not_exported_tools.append(tool)
+ continue
+ if not entry_to_export.exportable:
+ log.info('Tool %s is not exportable. Skipping.' % tool)
+ not_exported_tools.append(tool)
+ continue
log.info('Exporting %s...' % tool)
try:
path = create_export_dir(project)
with open(os.path.join(path, '%s.json' % tool), 'w') as f:
- with h.push_context(project._id, app_config_id=app.config._id):
- app.bulk_export(f)
+ with h.push_context(project._id):
+ entry_to_export.bulk_export(f)
except:
log.error('Something went wrong during export of %s' % tool, exc_info=True)
not_exported_tools.append(tool)
continue
- try:
- path = create_export_dir(project)
- with open(os.path.join(path, 'project.json'), 'w') as f:
- json.dump(project, f, cls=tg.jsonify.GenericJSON, indent=2)
- except:
- log.error('Something went wrong during export of project metadata', exc_info=True)
-
if tools and len(not_exported_tools) < len(tools):
# If that fails, we need to let it fail
# there won't be a valid zip file for the user to get.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e5bcf01a/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index bc16982..9703b76 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -783,9 +783,12 @@ class TestExport(TestController):
def test_exportable_tools_for(self):
project = M.Project.query.get(shortname='test')
+ exportable_tools = AdminApp.exportable_tools_for(project)
tools = [t.options.mount_point
- for t in AdminApp.exportable_tools_for(project)]
+ for t in AdminApp.exportable_tools_for(project)
+ if hasattr(t, 'options')]
assert_equals(tools, [u'wiki', u'wiki2'])
+ assert_in(project, exportable_tools)
def test_access(self):
r = self.app.get('/admin/export',
@@ -820,8 +823,11 @@ class TestExport(TestController):
def test_export_page_contains_hidden_tools(self):
with patch('allura.ext.search.search_main.SearchApp.exportable'):
project = M.Project.query.get(shortname='test')
- tools = [t.options.mount_point for t in AdminApp.exportable_tools_for(project)]
+ exportable_tools = AdminApp.exportable_tools_for(project)
+ tools = [t.options.mount_point for t in exportable_tools
+ if hasattr(t, 'options')]
assert_equals(tools, [u'search', u'wiki', u'wiki2'])
+ assert_in(project, exportable_tools)
def test_tools_not_selected(self):
r = self.app.post('/admin/export')
[12/50] git commit: [#3153] ticket:389 bulk_export outline for tracker
Posted by jo...@apache.org.
[#3153] ticket:389 bulk_export outline for tracker
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/21ed41e3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/21ed41e3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/21ed41e3
Branch: refs/heads/cj/6530
Commit: 21ed41e3aa84f24a03d3b01b4e4e675b9082606d
Parents: f0d671e
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Mon Jul 22 19:23:02 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:41 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/helpers.py | 9 ++++-
ForgeTracker/forgetracker/tests/test_app.py | 47 ++++++++++++++++++++++++
ForgeTracker/forgetracker/tracker_main.py | 14 ++++++-
3 files changed, 68 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/21ed41e3/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index e68eafb..8095f79 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -363,7 +363,14 @@ class DateTimeConverter(FancyValidator):
def absurl(url):
if url is None: return None
if '://' in url: return url
- return request.scheme + '://' + request.host + url
+ # some __json__ methods call absurl
+ # and in tests request is not set so exception raises
+ # this check prevents it
+ try:
+ host = request.scheme + '://' + request.host
+ except TypeError:
+ host = ''
+ return host + url
def diff_text(t1, t2, differ=None):
t1_lines = t1.replace('\r', '').split('\n')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/21ed41e3/ForgeTracker/forgetracker/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
new file mode 100644
index 0000000..9c7e61e
--- /dev/null
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import datetime
+import tempfile
+import json
+import operator
+
+from nose.tools import assert_equal
+
+from allura import model as M
+from allura.tests import decorators as td
+from forgetracker import model as TM
+from forgetracker.tests.functional.test_root import TrackerTestController
+
+
+class TestBulkExport(TrackerTestController):
+ @td.with_tracker
+ def setup_with_tools(self):
+ super(TestBulkExport, self).setup_with_tools()
+ self.project = M.Project.query.get(shortname='test')
+ self.tracker = self.project.app_instance('bugs')
+ self.new_ticket(summary='foo', _milestone='1.0')
+
+ def test_bulk_export(self):
+ f = tempfile.TemporaryFile()
+ self.tracker.bulk_export(f)
+ f.seek(0)
+ tracker = json.loads(f.read())
+ #tickets = sorted(tracker['tickets'], key=operator.itemgetter('title'))
+ tickets = tracker['tickets']
+ print tickets
+ assert_equal(len(tickets), 1)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/21ed41e3/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index cc28879..ff540c3 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -28,7 +28,7 @@ import jinja2
# Non-stdlib imports
import pkg_resources
-from tg import expose, validate, redirect, flash, url, config
+from tg import expose, validate, redirect, flash, url, config, jsonify
from tg.decorators import with_trailing_slash, without_trailing_slash
from paste.deploy.converters import aslist
from pylons import tmpl_context as c, app_globals as g
@@ -407,6 +407,18 @@ class ForgeTrackerApp(Application):
TM.Globals.query.remove(app_config_id)
super(ForgeTrackerApp, self).uninstall(project)
+ def bulk_export(self, f):
+ f.write('{"tickets": [')
+ tickets = TM.Ticket.query.find(dict(
+ app_config_id=self.config._id,
+ deleted=False)).all()
+ count = len(tickets)
+ for i, ticket in enumerate(tickets):
+ json.dump(ticket, f, cls=jsonify.GenericJSON)
+ if i < (count - 1):
+ f.write(',')
+ f.write(']}')
+
@property
def bins(self):
return TM.Bin.query.find(dict(app_config_id=self.config._id)).sort('summary').all()
[27/50] git commit: [#3154] ticket:411 added exportable to
Application docstring
Posted by jo...@apache.org.
[#3154] ticket:411 added exportable to Application docstring
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/9a39fcaf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9a39fcaf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9a39fcaf
Branch: refs/heads/cj/6530
Commit: 9a39fcaf657cb4e29f6f916e67add7ee27aee436
Parents: b2e246d
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Aug 13 16:16:30 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:44 2013 +0000
----------------------------------------------------------------------
Allura/allura/app.py | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9a39fcaf/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index be2f70a..5de6a12 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -174,6 +174,7 @@ class Application(object):
is 'production'.
:cvar bool searchable: If True, show search box in the left menu of this
Application. Default is True.
+ :cvar bool exportable: Default is False, Application can't be exported to json.
:cvar list permissions: Named permissions used by instances of this
Application. Default is [].
:cvar dict permissions_desc: Descriptions of the named permissions.
[43/50] git commit: [#3154] call bulk_export_filename() just once per
export; better status check; include filename & `c` in config templates
Posted by jo...@apache.org.
[#3154] call bulk_export_filename() just once per export; better status check; include filename & `c` in config templates
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/a779ed79
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a779ed79
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a779ed79
Branch: refs/heads/cj/6530
Commit: a779ed7993bddd2f32e5d69cee5c126a988397a0
Parents: 587f2d3
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Aug 19 18:23:31 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:46 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 3 +-
Allura/allura/ext/admin/templates/export.html | 12 ++---
Allura/allura/model/project.py | 27 +++++++---
Allura/allura/tasks/export_tasks.py | 58 ++++++++++++----------
Allura/allura/tests/functional/test_admin.py | 30 +++--------
Allura/allura/tests/test_tasks.py | 43 ++++------------
6 files changed, 76 insertions(+), 97 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a779ed79/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 cbb1e2c..0e33c94 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -652,9 +652,10 @@ class ProjectAdminController(BaseController):
if c.project.bulk_export_status() == 'busy':
flash('Export for project %s already running' % c.project.shortname, 'info')
redirect('export')
- export_tasks.bulk_export.post(c.project.shortname, tools, c.user.username, c.project.neighborhood.name)
+ export_tasks.bulk_export.post(tools)
flash('Export scheduled', 'ok')
redirect('export')
+
return {
'tools': exportable_tools,
'status': c.project.bulk_export_status()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a779ed79/Allura/allura/ext/admin/templates/export.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/export.html b/Allura/allura/ext/admin/templates/export.html
index eff9d5a..f0429c2 100644
--- a/Allura/allura/ext/admin/templates/export.html
+++ b/Allura/allura/ext/admin/templates/export.html
@@ -24,12 +24,10 @@
{% block content %}
-{% if status == 'ready' %}
-<div class="error">
- <h2>Careful!</h2>
- This project has been exported already.
- Follow instructions in notification email to get the exported data.
- If you run export again previous exported data will be lost.
+{% if status == 'busy' %}
+<div class="info">
+ <h2>Busy</h2>
+ This project is queued for export. You can't start another export yet.
</div>
{% endif %}
@@ -42,7 +40,7 @@
<label for="tool-{{ loop.index }}">{{ tool.options.mount_label }}</label> <a href="{{ tool.url() }}">{{ tool.url() }}</a>
</div>
{% endfor %}
- <p><div class="grid-19"><input type="submit" value="Export"></div></p>
+ <p><div class="grid-19"><input type="submit" value="Export" {% if status == 'busy' %}disabled{% endif %}></div></p>
</form>
{% else %}
There are no exportable tools in your project.
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a779ed79/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 95ad80f..f57dc34 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -46,6 +46,7 @@ from .neighborhood import Neighborhood
from .auth import ProjectRole, User
from .timeline import ActivityNode, ActivityObject
from .types import ACL, ACE
+from .monq_model import MonQTask
from filesystem import File
@@ -855,9 +856,15 @@ class Project(MappedClass, ActivityNode, ActivityObject):
shortname = self.shortname.split('/')[0]
return config['bulk_export_path'].format(
nbhd=self.neighborhood.url_prefix.strip('/'),
- project=shortname)
+ project=shortname,
+ c=c,
+ )
def bulk_export_filename(self):
+ '''
+ Return a filename (configurable) for this project export. The current timestamp
+ may be included, so only run this method once per export.
+ '''
shortname = self.shortname
if self.is_nbhd_project:
shortname = self.url().strip('/')
@@ -869,13 +876,21 @@ class Project(MappedClass, ActivityNode, ActivityObject):
return config['bulk_export_filename'].format(project=shortname, date=datetime.utcnow())
def bulk_export_status(self):
- fn = os.path.join(self.bulk_export_path(), self.bulk_export_filename())
- tmpdir = os.path.join(self.bulk_export_path(), self.shortname)
- if os.path.isfile(fn):
- return 'ready'
- elif os.path.exists(tmpdir):
+ '''
+ Returns 'busy' if an export is queued or in-progress. Returns None otherwise
+ '''
+ q = {
+ 'task_name': 'allura.tasks.export_tasks.bulk_export',
+ 'state': {'$in': ['busy', 'ready']},
+ 'context.project_id': self._id,
+ }
+ export_task = MonQTask.query.get(**q)
+ if not export_task:
+ return
+ if export_task.state in ('busy', 'ready'):
return 'busy'
+
def __json__(self):
return dict(
shortname=self.shortname,
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a779ed79/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index b6a84ac..ee07057 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -15,14 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-import json
import os
import logging
import shutil
from tempfile import mkstemp
import tg
-from pylons import app_globals as g
+from pylons import app_globals as g, tmpl_context as c
from allura import model as M
from allura.tasks import mail_tasks
@@ -35,15 +34,19 @@ log = logging.getLogger(__name__)
@task
-def bulk_export(project_shortname, tools, username, neighborhood):
- neighborhood = M.Neighborhood.query.get(name=neighborhood)
- project = M.Project.query.get(shortname=project_shortname, neighborhood_id=neighborhood._id)
- if not project:
- log.error('Project %s not found' % project_shortname)
- return
- if project.bulk_export_status() == 'busy':
- log.info('Another export is running for project %s. Skipping.' % project_shortname)
- return
+def bulk_export(tools):
+ '''
+ Export the current project data. Send notification to current user
+
+ :param list tools: list of mount_points to export
+ '''
+ # it's very handy to use c.* within a @task,
+ # but let's be explicit and keep it separate from the main code
+ return _bulk_export(c.project, tools, c.user)
+
+
+def _bulk_export(project, tools, user):
+ export_filename = project.bulk_export_filename()
not_exported_tools = []
for tool in tools or []:
app = project.app_instance(tool)
@@ -57,7 +60,7 @@ def bulk_export(project_shortname, tools, username, neighborhood):
continue
log.info('Exporting %s...' % tool)
try:
- path = create_export_dir(project)
+ path = create_export_dir(project, export_filename)
temp_name = mkstemp(dir=path)[1]
with open(temp_name, 'w') as f:
with h.push_context(project._id):
@@ -71,17 +74,17 @@ def bulk_export(project_shortname, tools, username, neighborhood):
if tools and len(not_exported_tools) < len(tools):
# If that fails, we need to let it fail
# there won't be a valid zip file for the user to get.
- zip_and_cleanup(project)
+ zip_and_cleanup(project, export_filename)
else:
log.error('Nothing to export')
+ None
- user = M.User.by_username(username)
if not user:
- log.info('Can not find user %s. Skipping notification.' % username)
+ log.info('No user. Skipping notification.')
return
tmpl = g.jinja2_env.get_template('allura:templates/mail/bulk_export.html')
instructions = tg.config.get('bulk_export_download_instructions', '')
- instructions = instructions.format(project=project.shortname)
+ instructions = instructions.format(project=project.shortname, filename=export_filename, c=c)
tmpl_context = {
'instructions': instructions,
'project': project,
@@ -93,34 +96,35 @@ def bulk_export(project_shortname, tools, username, neighborhood):
'reply_to': unicode(user.email_address_header()),
'message_id': h.gen_message_id(),
'destinations': [unicode(user._id)],
- 'subject': u'Bulk export for project %s completed' % project_shortname,
+ 'subject': u'Bulk export for project %s completed' % project.shortname,
'text': tmpl.render(tmpl_context),
}
mail_tasks.sendmail.post(**email)
-def create_export_dir(project):
+def create_export_dir(project, export_filename):
"""Create temporary directory for export files"""
- zip_fn = project.bulk_export_filename()
# Name temporary directory after project shortname,
# thus zipdir() will use proper prefix inside the archive.
- tmp_dir_suffix = zip_fn.split('.')[0]
+ tmp_dir_suffix = export_filename.split('.')[0]
path = os.path.join(project.bulk_export_path(), tmp_dir_suffix)
if not os.path.exists(path):
os.makedirs(path)
return path
-def zip_and_cleanup(project):
- """Zip exported data. Copy it to proper location. Remove temporary files."""
+def zip_and_cleanup(project, export_filename):
+ """
+ Zip exported data. Copy it to proper location. Remove temporary files.
+ Returns base filename of zip file
+ """
path = project.bulk_export_path()
- zip_fn = project.bulk_export_filename()
- temp = os.path.join(path, zip_fn.split('.')[0])
- zip_path_temp = os.path.join(temp, zip_fn)
- zip_path = os.path.join(path, zip_fn)
+ temp = os.path.join(path, export_filename.split('.')[0])
+ zip_path_temp = os.path.join(temp, export_filename)
+ zip_path = os.path.join(path, export_filename)
zipdir(temp, zip_path_temp)
# cleanup
shutil.move(zip_path_temp, zip_path)
- shutil.rmtree(temp)
+ shutil.rmtree(temp)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a779ed79/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 669f113..9c5aed6 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -836,37 +836,19 @@ class TestExport(TestController):
def test_selected_one_tool(self, export_tasks):
r = self.app.post('/admin/export', {'tools': u'wiki'})
assert_in('ok', self.webflash(r))
- export_tasks.bulk_export.post.assert_called_once_with(
- 'test', [u'wiki'], u'test-admin', u'Projects')
+ export_tasks.bulk_export.post.assert_called_once_with([u'wiki'])
@mock.patch('allura.ext.admin.admin_main.export_tasks')
def test_selected_multiple_tools(self, export_tasks):
r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
assert_in('ok', self.webflash(r))
- export_tasks.bulk_export.post.assert_called_once_with(
- 'test', [u'wiki', u'wiki2'], u'test-admin', u'Projects')
+ export_tasks.bulk_export.post.assert_called_once_with([u'wiki', u'wiki2'])
- @mock.patch('allura.ext.admin.admin_main.export_tasks')
- def test_export_in_progress(self, export_tasks):
- p = M.Project.query.get(shortname='test')
- tmpdir = os.path.join(p.bulk_export_path(), p.shortname)
- shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
- os.makedirs(tmpdir)
- r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
- assert_in('info', self.webflash(r))
- assert_equals(export_tasks.bulk_export.post.call_count, 0)
- shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
-
- def test_export_done(self):
- p = M.Project.query.get(shortname='test')
- shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
- os.makedirs(p.bulk_export_path())
- fn = os.path.join(p.bulk_export_path(), p.bulk_export_filename())
- with open(fn, 'w') as f:
- f.write('Pretending I am zip archive')
+ def test_export_in_progress(self):
+ from allura.tasks import export_tasks
+ export_tasks.bulk_export.post(['wiki'])
r = self.app.get('/admin/export')
- assert_in('<h2>Careful!</h2>', r)
- shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
+ assert_in('<h2>Busy</h2>', r.body)
@td.with_user_project('test-user')
def test_bulk_export_path_for_user_project(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a779ed79/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index a1e09c3..9f307ee 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -341,13 +341,8 @@ class TestExportTasks(unittest.TestCase):
shutil.rmtree(project.bulk_export_path(), ignore_errors=True)
@mock.patch('allura.tasks.export_tasks.log')
- def test_bulk_export_invalid_project(self, log):
- export_tasks.bulk_export('bad', [u'wiki'], 'test-admin', 'Projects')
- log.error.assert_called_once_with('Project bad not found')
-
- @mock.patch('allura.tasks.export_tasks.log')
def test_bulk_export_invalid_tool(self, log):
- export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin', 'Projects')
+ export_tasks.bulk_export([u'bugs', u'blog'])
assert_equal(log.info.call_count, 2)
assert_equal(log.info.call_args_list, [
mock.call('Can not load app for bugs mount point. Skipping.'),
@@ -360,7 +355,7 @@ class TestExportTasks(unittest.TestCase):
@td.with_tool('test', 'Blog', 'blog')
def test_bulk_export_not_exportable_tool(self, mail_tasks, app, log):
app.return_value.exportable = False
- export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin', 'Projects')
+ export_tasks.bulk_export([u'bugs', u'blog'])
assert_equal(log.info.call_count, 2)
assert_equal(log.info.call_args_list, [
mock.call('Tool bugs is not exportable. Skipping.'),
@@ -374,7 +369,7 @@ class TestExportTasks(unittest.TestCase):
@td.with_wiki
def test_bulk_export(self, log, wiki_bulk_export, zipdir, shutil, project_json):
M.MonQTask.query.remove()
- export_tasks.bulk_export('test', [u'wiki'], 'test-admin', 'Projects')
+ export_tasks.bulk_export([u'wiki'])
assert_equal(log.info.call_count, 1)
assert_equal(log.info.call_args_list, [
mock.call('Exporting wiki...')])
@@ -396,21 +391,11 @@ class TestExportTasks(unittest.TestCase):
assert_in('The following tools were exported:\n- wiki', text)
assert_in('Sample instructions for test', text)
- @mock.patch('forgewiki.wiki_main.ForgeWikiApp.bulk_export')
- @mock.patch('allura.tasks.export_tasks.log')
- @td.with_wiki
- def test_bulk_export_quits_if_another_export_is_running(self, log, wiki_bulk_export):
- project = M.Project.query.get(shortname='test')
- export_tasks.create_export_dir(project)
- assert_equal(project.bulk_export_status(), 'busy')
- export_tasks.bulk_export('test', [u'wiki'], 'test-admin', 'Projects')
- log.info.assert_called_once_with('Another export is running for project test. Skipping.')
- assert_equal(wiki_bulk_export.call_count, 0)
-
def test_create_export_dir(self):
project = M.Project.query.get(shortname='test')
export_path = project.bulk_export_path()
- path = export_tasks.create_export_dir(project)
+ export_filename = project.bulk_export_filename()
+ path = export_tasks.create_export_dir(project, export_filename)
assert_equal(path, '/tmp/bulk_export/p/test/test')
assert os.path.exists(os.path.join(export_path, project.shortname))
@@ -418,22 +403,16 @@ class TestExportTasks(unittest.TestCase):
def test_zip_and_cleanup(self):
project = M.Project.query.get(shortname='test')
export_path = project.bulk_export_path()
- path = export_tasks.create_export_dir(project)
- export_tasks.zip_and_cleanup(project)
+ export_filename = project.bulk_export_filename()
+ path = export_tasks.create_export_dir(project, export_filename)
+ export_tasks.zip_and_cleanup(project, export_filename)
assert not os.path.exists(path)
assert os.path.exists(os.path.join(export_path, 'test.zip'))
def test_bulk_export_status(self):
- project = M.Project.query.get(shortname='test')
- assert_equal(project.bulk_export_status(), None)
-
- export_tasks.create_export_dir(project)
- assert_equal(project.bulk_export_status(), 'busy')
-
- with open(os.path.join(project.bulk_export_path(),
- project.bulk_export_filename()), 'w') as f:
- f.write('just test')
- assert_equal(project.bulk_export_status(), 'ready')
+ assert_equal(c.project.bulk_export_status(), None)
+ export_tasks.bulk_export.post(['wiki'])
+ assert_equal(c.project.bulk_export_status(), 'busy')
Mapper.compile_all()
[32/50] git commit: [#3154] ticket:408 refactored export tests
Posted by jo...@apache.org.
[#3154] ticket:408 refactored export tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/cf72c2ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/cf72c2ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/cf72c2ef
Branch: refs/heads/cj/6530
Commit: cf72c2efa152ebbd24503e8da22447c690d83b1b
Parents: cfb95ae
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Mon Aug 12 14:23:27 2013 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:44 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/functional/test_admin.py | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cf72c2ef/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 6d17263..4fd0d19 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -806,12 +806,11 @@ class TestExport(TestController):
assert_in('Wiki2</label> <a href="/p/test/wiki2/">/p/test/wiki2/</a>', r)
assert_not_in('Search</label> <a href="/p/test/search/">/p/test/search/</a>', r)
- @patch('allura.ext.search.search_main.SearchApp.exportable')
- def test_export_page_contains_hidden_tools(self, search_app):
- project = M.Project.query.get(shortname='test')
- tools = [t.options.mount_point
- for t in AdminApp.exportable_tools_for(project)]
- assert_equals(tools, [u'search', u'wiki', u'wiki2'])
+ def test_export_page_contains_hidden_tools(self):
+ with patch('allura.ext.search.search_main.SearchApp.exportable'):
+ project = M.Project.query.get(shortname='test')
+ tools = [t.options.mount_point for t in AdminApp.exportable_tools_for(project)]
+ assert_equals(tools, [u'search', u'wiki', u'wiki2'])
def test_tools_not_selected(self):
r = self.app.post('/admin/export')
@@ -842,7 +841,6 @@ class TestExport(TestController):
shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
os.makedirs(tmpdir)
r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
- r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
assert_in('info', self.webflash(r))
assert_equals(export_tasks.bulk_export.post.call_count, 0)
shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
[10/50] git commit: [#3154] ticket:394 Set up context before calling
bulk_export
Posted by jo...@apache.org.
[#3154] ticket:394 Set up context before calling bulk_export
Also, use controller's method inside ForgeLink's bulk_export()
to get app's json representation to avoid code duplication.
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0b4c11b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0b4c11b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0b4c11b1
Branch: refs/heads/cj/6530
Commit: 0b4c11b1d0c14f8d65849ce60d96d552b656f646
Parents: aeaaa11
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Jul 23 13:48:26 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:41 2013 +0000
----------------------------------------------------------------------
Allura/allura/tasks/export_tasks.py | 3 ++-
ForgeLink/forgelink/link_main.py | 10 +++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0b4c11b1/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 672f51b..9001500 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -56,7 +56,8 @@ def bulk_export(project_shortname, tools, username):
try:
path = create_export_dir(project)
with open(os.path.join(path, '%s.json' % tool), 'w') as f:
- app.bulk_export(f)
+ with h.push_context(project._id, app_config_id=app.config._id):
+ app.bulk_export(f)
except:
log.error('Something went wrong during export of %s' % tool, exc_info=True)
not_exported_tools.append(tool)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0b4c11b1/ForgeLink/forgelink/link_main.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index 2350e84..b5dd0d4 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -17,10 +17,11 @@
#-*- python -*-
import logging
+import json
# Non-stdlib imports
import pkg_resources
-from tg import expose, validate, redirect, response, flash
+from tg import expose, validate, redirect, response, flash, jsonify
from pylons import tmpl_context as c, app_globals as g
from pylons import request
@@ -95,7 +96,7 @@ class ForgeLinkApp(Application):
super(ForgeLinkApp, self).uninstall(project)
def bulk_export(self, f):
- f.write('{"url": "%s"}' % self.config.options.get('url', 'test'))
+ json.dump(RootRestController().link_json(), f, cls=jsonify.GenericJSON)
class RootController(BaseController):
@@ -132,9 +133,12 @@ class RootRestController(BaseController):
def _check_security(self):
require_access(c.app, 'read')
+ def link_json(self):
+ return dict(url=c.app.config.options.get('url'))
+
@expose('json:')
def index(self, url='', **kw):
if (request.method == 'POST') and (url != ''):
require_access(c.app, 'configure')
c.app.config.options.url = url
- return dict(url=c.app.config.options.get('url'))
+ return self.link_json()
[46/50] git commit: [#3154] add tests to make sure all bulk_exports
can run without context
Posted by jo...@apache.org.
[#3154] add tests to make sure all bulk_exports can run without context
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/719f6e9e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/719f6e9e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/719f6e9e
Branch: refs/heads/cj/6530
Commit: 719f6e9e901dc60babea400c607e9f410c1d0417
Parents: 031f9ae
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Aug 21 18:29:50 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:49:29 2013 +0000
----------------------------------------------------------------------
ForgeBlog/forgeblog/tests/test_app.py | 32 ++++++++++++--------
.../forgediscussion/tests/test_app.py | 6 ++++
ForgeLink/forgelink/link_main.py | 15 +++++----
ForgeLink/forgelink/tests/test_app.py | 15 +++++----
ForgeWiki/forgewiki/tests/test_app.py | 5 +++
5 files changed, 48 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/719f6e9e/ForgeBlog/forgeblog/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/test_app.py b/ForgeBlog/forgeblog/tests/test_app.py
index 7427b9b..895bb06 100644
--- a/ForgeBlog/forgeblog/tests/test_app.py
+++ b/ForgeBlog/forgeblog/tests/test_app.py
@@ -19,7 +19,9 @@
import tempfile
import json
+
from nose.tools import assert_equal
+from pylons import tmpl_context as c
from allura import model as M
from allura.lib import helpers as h
@@ -36,21 +38,25 @@ class TestBulkExport(object):
@td.with_tool('test', 'Blog', 'blog')
def test_bulk_export(self):
+ # Clear out some context vars, to properly simulate how this is run from the export task
+ # Besides, it's better not to need c context vars
+ c.app = c.project = None
+
project = M.Project.query.get(shortname='test')
blog = project.app_instance('blog')
- h.set_context('test', 'blog', neighborhood='Projects')
- post = BM.BlogPost()
- post.title = 'Test title'
- post.text = 'test post'
- post.labels = ['the firstlabel', 'the second label']
- post.make_slug()
- post.commit()
- post.discussion_thread.add_post(text='test comment')
- post2 = BM.BlogPost()
- post2.title = 'Test2 title'
- post2.text = 'test2 post'
- post2.make_slug()
- post2.commit()
+ with h.push_context('test', 'blog', neighborhood='Projects'):
+ post = BM.BlogPost()
+ post.title = 'Test title'
+ post.text = 'test post'
+ post.labels = ['the firstlabel', 'the second label']
+ post.make_slug()
+ post.commit()
+ post.discussion_thread.add_post(text='test comment')
+ post2 = BM.BlogPost()
+ post2.title = 'Test2 title'
+ post2.text = 'test2 post'
+ post2.make_slug()
+ post2.commit()
f = tempfile.TemporaryFile()
blog.bulk_export(f)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/719f6e9e/ForgeDiscussion/forgediscussion/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/test_app.py b/ForgeDiscussion/forgediscussion/tests/test_app.py
index 07b65f4..3666821 100644
--- a/ForgeDiscussion/forgediscussion/tests/test_app.py
+++ b/ForgeDiscussion/forgediscussion/tests/test_app.py
@@ -21,7 +21,9 @@
import tempfile
import json
+
from nose.tools import assert_equal
+from pylons import tmpl_context as c
from allura import model as M
from forgediscussion.tests.functional.test_rest import TestDiscussionApiBase
@@ -30,6 +32,10 @@ from forgediscussion.tests.functional.test_rest import TestDiscussionApiBase
class TestBulkExport(TestDiscussionApiBase):
def test_bulk_export(self):
+ # Clear out some context vars, to properly simulate how this is run from the export task
+ # Besides, it's better not to need c context vars
+ c.app = c.project = None
+
project = M.Project.query.get(shortname='test')
discussion = project.app_instance('discussion')
f = tempfile.TemporaryFile()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/719f6e9e/ForgeLink/forgelink/link_main.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index 199304a..d37db1b 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -65,7 +65,7 @@ class ForgeLinkApp(Application):
Application.__init__(self, project, config)
self.root = RootController()
self.admin = LinkAdminController(self)
- self.api_root = RootRestController()
+ self.api_root = RootRestController(self)
@property
@h.exceptionless([], log)
@@ -96,7 +96,7 @@ class ForgeLinkApp(Application):
super(ForgeLinkApp, self).uninstall(project)
def bulk_export(self, f):
- json.dump(RootRestController().link_json(), f, cls=jsonify.GenericJSON, indent=2)
+ json.dump(RootRestController(self).link_json(), f, cls=jsonify.GenericJSON, indent=2)
class RootController(BaseController):
@@ -130,15 +130,18 @@ class LinkAdminController(DefaultAdminController):
class RootRestController(BaseController):
+ def __init__(self, app):
+ self.app = app
+
def _check_security(self):
- require_access(c.app, 'read')
+ require_access(self.app, 'read')
def link_json(self):
- return dict(url=c.app.config.options.get('url'))
+ return dict(url=self.app.config.options.get('url'))
@expose('json:')
def index(self, url='', **kw):
if (request.method == 'POST') and (url != ''):
- require_access(c.app, 'configure')
- c.app.config.options.url = url
+ require_access(self.app, 'configure')
+ self.app.config.options.url = url
return self.link_json()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/719f6e9e/ForgeLink/forgelink/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/tests/test_app.py b/ForgeLink/forgelink/tests/test_app.py
index 3290aa2..8149815 100644
--- a/ForgeLink/forgelink/tests/test_app.py
+++ b/ForgeLink/forgelink/tests/test_app.py
@@ -19,10 +19,10 @@ import tempfile
import json
from nose.tools import assert_equal
+from pylons import tmpl_context as c
from allura.tests import decorators as td
from allura import model as M
-from allura.lib import helpers as h
from alluratest.controller import setup_basic_test
@@ -33,11 +33,14 @@ class TestBulkExport(object):
@td.with_link
def test_bulk_export(self):
- self.project = M.Project.query.get(shortname='test')
- self.link = self.project.app_instance('link')
- h.set_context(self.project._id, app_config_id=self.link.config._id)
- self.link.config.options['url'] = 'http://sf.net'
+ # Clear out some context vars, to properly simulate how this is run from the export task
+ # Besides, it's better not to need c context vars
+ c.app = c.project = None
+
+ project = M.Project.query.get(shortname='test')
+ link = project.app_instance('link')
+ link.config.options['url'] = 'http://sf.net'
f = tempfile.TemporaryFile()
- self.link.bulk_export(f)
+ link.bulk_export(f)
f.seek(0)
assert_equal(json.loads(f.read())['url'], 'http://sf.net')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/719f6e9e/ForgeWiki/forgewiki/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/test_app.py b/ForgeWiki/forgewiki/tests/test_app.py
index b6db6a2..103def4 100644
--- a/ForgeWiki/forgewiki/tests/test_app.py
+++ b/ForgeWiki/forgewiki/tests/test_app.py
@@ -21,6 +21,7 @@ import json
import operator
from nose.tools import assert_equal
+from pylons import tmpl_context as c
from allura import model as M
from allura.tests import decorators as td
@@ -57,6 +58,10 @@ class TestBulkExport(object):
page.commit()
def test_bulk_export(self):
+ # Clear out some context vars, to properly simulate how this is run from the export task
+ # Besides, it's better not to need c context vars
+ c.app = c.project = None
+
f = tempfile.TemporaryFile()
self.wiki.bulk_export(f)
f.seek(0)
[15/50] git commit: [#3154] ticket:390 Bulk export: discussion
Posted by jo...@apache.org.
[#3154] ticket:390 Bulk export: discussion
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d79c80b5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d79c80b5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d79c80b5
Branch: refs/heads/cj/6530
Commit: d79c80b59943eaa896d69b4e234b499fa530828f
Parents: 8883480
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Fri Jul 26 10:31:30 2013 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:42 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/discuss.py | 9 ++--
ForgeDiscussion/forgediscussion/forum_main.py | 14 +++++-
ForgeDiscussion/forgediscussion/model/forum.py | 6 ---
.../forgediscussion/tests/test_app.py | 50 ++++++++++++++++++++
4 files changed, 69 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d79c80b5/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index d13b7e9..ec5ccdc 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -64,8 +64,9 @@ class Discussion(Artifact, ActivityObject):
shortname=self.shortname,
name=self.name,
description=self.description,
- threads=[dict(_id=t._id, subject=t.subject)
- for t in self.threads])
+ threads=[t.__json__() for t in self.thread_class().query.find(
+ dict(discussion_id=self._id)).sort(
+ 'last_post_date', pymongo.DESCENDING)])
@property
def activity_name(self):
@@ -169,7 +170,9 @@ class Thread(Artifact, ActivityObject):
subject=p.subject,
attachments=[dict(bytes=attach.length,
url=h.absurl(attach.url())) for attach in p.attachments])
- for p in self.posts if p.status == 'ok'])
+ for p in self.post_class().query.find(
+ dict(discussion_id=self.discussion_id, thread_id=self._id, status='ok')
+ ).sort('timestamp', pymongo.DESCENDING)])
@property
def activity_name(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d79c80b5/ForgeDiscussion/forgediscussion/forum_main.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index 730f007..2465312 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -19,12 +19,13 @@
import logging
import urllib
from itertools import islice
+import json
# Non-stdlib imports
import pymongo
from pylons import tmpl_context as c, app_globals as g
from pylons import request
-from tg import expose, redirect, flash, url, validate
+from tg import expose, redirect, flash, url, validate, jsonify
from tg.decorators import with_trailing_slash
from bson import ObjectId
from ming import schema
@@ -67,6 +68,7 @@ class ForgeDiscussionApp(Application):
PostClass=DM.ForumPost
AttachmentClass=DM.ForumAttachment
searchable=True
+ exportable=True
tool_label='Discussion'
tool_description="""
Collaborate with your community in your forum.
@@ -215,6 +217,16 @@ class ForgeDiscussionApp(Application):
DM.ForumPost.query.remove(dict(app_config_id=self.config._id))
super(ForgeDiscussionApp, self).uninstall(project)
+ def bulk_export(self, f):
+ f.write('{"forums": [')
+ forums = DM.Forum.query.find(dict(app_config_id=self.config._id)).sort('mod_date', pymongo.DESCENDING).all()
+ count = len(forums)
+ for i, forum in enumerate(forums):
+ json.dump(forum, f, cls=jsonify.GenericJSON)
+ if i < (count - 1):
+ f.write(',')
+ f.write(']}')
+
class ForumAdminController(DefaultAdminController):
def _check_security(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d79c80b5/ForgeDiscussion/forgediscussion/model/forum.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/model/forum.py b/ForgeDiscussion/forgediscussion/model/forum.py
index 42d1dc0..84040da 100644
--- a/ForgeDiscussion/forgediscussion/model/forum.py
+++ b/ForgeDiscussion/forgediscussion/model/forum.py
@@ -194,12 +194,6 @@ class ForumThread(M.Thread):
{'$set':dict(discussion_id=new_forum._id)})
self.discussion_id = new_forum._id
- def __json__(self):
- return dict(
- _id=self._id,
- discussion_id=str(self.discussion_id),
- subject=self.subject)
-
class ForumPostHistory(M.PostHistory):
class __mongometa__:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d79c80b5/ForgeDiscussion/forgediscussion/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/test_app.py b/ForgeDiscussion/forgediscussion/tests/test_app.py
new file mode 100644
index 0000000..d54ab5a
--- /dev/null
+++ b/ForgeDiscussion/forgediscussion/tests/test_app.py
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#-*- python -*-
+
+import tempfile
+import json
+from nose.tools import assert_equal
+
+from allura import model as M
+from forgediscussion.tests.functional.test_rest import TestDiscussionApiBase
+
+
+class TestBulkExport(TestDiscussionApiBase):
+
+ def test_bulk_export(self):
+ project = M.Project.query.get(shortname='test')
+ discussion = project.app_instance('discussion')
+ f = tempfile.TemporaryFile()
+ discussion.bulk_export(f)
+ f.seek(0)
+ discussion = json.loads(f.read())
+ forums = discussion['forums']
+
+ assert_equal(forums[0]['shortname'], u'general')
+ assert_equal(forums[0]['description'], u'Forum about anything you want to talk about.')
+ assert_equal(forums[0]['name'], u'General Discussion')
+ assert_equal(forums[0]['threads'][0]['posts'][0]['text'], u'Hi boys and girls')
+ assert_equal(forums[0]['threads'][0]['posts'][0]['subject'], u'Hi guys')
+ assert_equal(forums[0]['threads'][1]['posts'][0]['text'], u'1st post')
+ assert_equal(forums[0]['threads'][1]['posts'][0]['subject'], u"Let's talk")
+ assert_equal(forums[1]['shortname'], u'héllo')
+ assert_equal(forums[1]['description'], u'Say héllo here')
+ assert_equal(forums[1]['name'], u'Say Héllo')
[09/50] git commit: [#3154] ticket:394 Fix test
Posted by jo...@apache.org.
[#3154] ticket:394 Fix test
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/f0d671e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/f0d671e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/f0d671e4
Branch: refs/heads/cj/6530
Commit: f0d671e4fc8ecaf7bc4f44b78dcd506a4b6fbb96
Parents: 0b4c11b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Jul 23 14:19:03 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:41 2013 +0000
----------------------------------------------------------------------
ForgeLink/forgelink/tests/test_app.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/f0d671e4/ForgeLink/forgelink/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/tests/test_app.py b/ForgeLink/forgelink/tests/test_app.py
index 2176b10..3290aa2 100644
--- a/ForgeLink/forgelink/tests/test_app.py
+++ b/ForgeLink/forgelink/tests/test_app.py
@@ -18,8 +18,11 @@
import tempfile
import json
+from nose.tools import assert_equal
+
from allura.tests import decorators as td
from allura import model as M
+from allura.lib import helpers as h
from alluratest.controller import setup_basic_test
@@ -32,8 +35,9 @@ class TestBulkExport(object):
def test_bulk_export(self):
self.project = M.Project.query.get(shortname='test')
self.link = self.project.app_instance('link')
+ h.set_context(self.project._id, app_config_id=self.link.config._id)
self.link.config.options['url'] = 'http://sf.net'
f = tempfile.TemporaryFile()
self.link.bulk_export(f)
f.seek(0)
- assert json.loads(f.read())['url']=='http://sf.net'
\ No newline at end of file
+ assert_equal(json.loads(f.read())['url'], 'http://sf.net')
[02/50] git commit: [#3154] ticket:388 Export wiki
Posted by jo...@apache.org.
[#3154] ticket:388 Export wiki
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b5f79e6f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b5f79e6f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b5f79e6f
Branch: refs/heads/cj/6530
Commit: b5f79e6fa5a9dd405f59bc1890026de8d97e018e
Parents: 449d9e7
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jul 5 13:45:13 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:40 2013 +0000
----------------------------------------------------------------------
ForgeWiki/forgewiki/tests/test_app.py | 78 ++++++++++++++++++++++++++++++
ForgeWiki/forgewiki/wiki_main.py | 15 ++++--
2 files changed, 90 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b5f79e6f/ForgeWiki/forgewiki/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/test_app.py b/ForgeWiki/forgewiki/tests/test_app.py
new file mode 100644
index 0000000..b6db6a2
--- /dev/null
+++ b/ForgeWiki/forgewiki/tests/test_app.py
@@ -0,0 +1,78 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import datetime
+import tempfile
+import json
+import operator
+
+from nose.tools import assert_equal
+
+from allura import model as M
+from allura.tests import decorators as td
+from alluratest.controller import setup_basic_test, setup_global_objects
+from forgewiki import model as WM
+
+
+class TestBulkExport(object):
+
+ def setUp(self):
+ setup_basic_test()
+ setup_global_objects()
+ self.setup_with_tools()
+
+ @td.with_wiki
+ def setup_with_tools(self):
+ self.project = M.Project.query.get(shortname='test')
+ self.wiki = self.project.app_instance('wiki')
+ page = WM.Page.upsert('A New Hope')
+ page.text = 'Star Wars Episode IV: A New Hope'
+ page.mod_date = datetime.datetime(2013, 7, 5)
+ page.labels = ['star wars', 'movies']
+ page.commit()
+ page.discussion_thread.add_post(text='Embrace the Dark Side')
+ page.discussion_thread.add_post(text='Nope')
+ page = WM.Page.upsert('The Empire Strikes Back')
+ page.text = 'Star Wars Episode V: The Empire Strikes Back'
+ page.commit()
+ page = WM.Page.upsert('Return of the Jedi')
+ page.text = 'Star Wars Episode VI: Return of the Jedi'
+ page.commit()
+ page = WM.Page.query.get(app_config_id=self.wiki.config._id, title='Home')
+ page.deleted = True
+ page.commit()
+
+ def test_bulk_export(self):
+ f = tempfile.TemporaryFile()
+ self.wiki.bulk_export(f)
+ f.seek(0)
+ wiki = json.loads(f.read())
+ pages = sorted(wiki['pages'], key=operator.itemgetter('title'))
+ assert_equal(len(pages), 3)
+ assert_equal(pages[0]['title'], 'A New Hope')
+ assert_equal(pages[0]['text'], 'Star Wars Episode IV: A New Hope')
+ assert_equal(pages[0]['mod_date'], '2013-07-05 00:00:00')
+ assert_equal(pages[0]['labels'], ['star wars', 'movies'])
+ assert_equal(len(pages[0]['discussion_thread']['posts']), 2)
+
+ assert_equal(pages[1]['title'], 'Return of the Jedi')
+ assert_equal(pages[1]['text'], 'Star Wars Episode VI: Return of the Jedi')
+ assert_equal(len(pages[1]['discussion_thread']['posts']), 0)
+
+ assert_equal(pages[2]['title'], 'The Empire Strikes Back')
+ assert_equal(pages[2]['text'], 'Star Wars Episode V: The Empire Strikes Back')
+ assert_equal(len(pages[2]['discussion_thread']['posts']), 0)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b5f79e6f/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 30b4860..f27ff73 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -16,13 +16,14 @@
# under the License.
#-*- python -*-
+import json
import logging
from pprint import pformat
from urllib import unquote
from datetime import datetime
# Non-stdlib imports
-from tg import expose, validate, redirect, response, flash
+from tg import expose, validate, redirect, response, flash, jsonify
from tg.decorators import with_trailing_slash, without_trailing_slash
from tg.controllers import RestController
from pylons import tmpl_context as c, app_globals as g
@@ -287,8 +288,16 @@ The wiki uses [Markdown](%s) syntax.
super(ForgeWikiApp, self).uninstall(project)
def bulk_export(self, f):
- # TODO: implement this
- f.write('{}\n')
+ f.write('{"pages": [')
+ pages = WM.Page.query.find(dict(
+ app_config_id=self.config._id,
+ deleted=False)).all()
+ count = len(pages)
+ for i, page in enumerate(pages):
+ json.dump(page, f, cls=jsonify.GenericJSON)
+ if i < (count - 1):
+ f.write(',')
+ f.write(']}')
class RootController(BaseController, DispatchIndex, FeedController):
[24/50] git commit: [#3154] only include options in config (exported
by Tracker tool). ACL and other fields aren't useful on their own
Posted by jo...@apache.org.
[#3154] only include options in config (exported by Tracker tool). ACL and other fields aren't useful on their own
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/9cbb5999
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9cbb5999
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9cbb5999
Branch: refs/heads/cj/6530
Commit: 9cbb59991a9ececb9ebe0013fe36d79eb4da6617
Parents: 6ee0e0d
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Aug 1 19:24:14 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:43 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/project.py | 6 ------
ForgeTracker/forgetracker/tests/test_app.py | 2 --
2 files changed, 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9cbb5999/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 2258c18..1b21d37 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -961,11 +961,5 @@ class AppConfig(MappedClass):
def __json__(self):
return dict(
_id=self._id,
- project_id=self.project_id,
- discussion_id=self.discussion_id,
- tool_name=self.tool_name,
- version=self.version,
options=self.options,
- tool_data=self.tool_data,
- acl=self.acl,
)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9cbb5999/ForgeTracker/forgetracker/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
index 0568829..b92a72f 100644
--- a/ForgeTracker/forgetracker/tests/test_app.py
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -55,9 +55,7 @@ class TestBulkExport(TrackerTestController):
assert_equal(posts_foo[0]['text'], 'silly comment')
tracker_config = tracker['tracker_config']
- assert_equal(tracker_config['project_id'], unicode(self.project._id))
assert_true('options' in tracker_config.keys())
- assert_true('acl' in tracker_config.keys())
assert_equal(tracker_config['options']['mount_point'], 'bugs')
milestones = sorted(tracker['milestones'], key=operator.itemgetter('name'))
[36/50] git commit: [#3154] ticket:411 tests for export ini option
Posted by jo...@apache.org.
[#3154] ticket:411 tests for export ini option
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/50ff5141
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/50ff5141
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/50ff5141
Branch: refs/heads/cj/6530
Commit: 50ff51415f4dcdf44c11c292076347fea06cf01c
Parents: 90077d5
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Wed Aug 14 13:22:40 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:45 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/functional/test_admin.py | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/50ff5141/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 9ee232f..bc16982 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -22,6 +22,7 @@ import pkg_resources
import StringIO
from contextlib import contextmanager
+import tg
import PIL
from nose.tools import assert_equals, assert_in, assert_not_in
from ming.orm.ormsession import ThreadLocalORMSession
@@ -800,6 +801,16 @@ class TestExport(TestController):
extra_environ={'username': 'test-user'},
status=403)
+ def test_ini_option(self):
+ tg.config['bulk_export_enabled'] = 'false'
+ r = self.app.get('/admin/')
+ assert_not_in('Export', r)
+ r = self.app.get('/admin/export').follow()
+ assert_equals(r.request.url, 'http://localhost/admin/')
+ tg.config['bulk_export_enabled'] = 'true'
+ r = self.app.get('/admin/')
+ assert_in('Export', r)
+
def test_export_page_contains_exportable_tools(self):
r = self.app.get('/admin/export')
assert_in('Wiki</label> <a href="/p/test/wiki/">/p/test/wiki/</a>', r)
[39/50] git commit: [#3154] ticket:410 used mkstemp with tmp file in
export
Posted by jo...@apache.org.
[#3154] ticket:410 used mkstemp with tmp file in export
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1e053432
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1e053432
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1e053432
Branch: refs/heads/cj/6530
Commit: 1e053432d438942dbc90b390dac2cdd8ee19bc96
Parents: b154525
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Wed Aug 14 17:14:04 2013 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:45 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/project.py | 3 ++-
Allura/allura/tasks/export_tasks.py | 5 ++++-
Allura/development.ini | 1 +
Allura/test.ini | 1 +
4 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e053432/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 41ea5c7..021bb47 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -866,7 +866,8 @@ class Project(MappedClass, ActivityNode, ActivityObject):
shortname = self.shortname.split('/')[1]
elif not self.is_root:
shortname = self.shortname.split('/')[1]
- return '%s.zip' % shortname
+
+ return config['bulk_export_filename'].format(project=shortname, date=datetime.utcnow())
def bulk_export_status(self):
fn = os.path.join(self.bulk_export_path(), self.bulk_export_filename())
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e053432/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index bbd4b1d..4b30c36 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -19,6 +19,7 @@ import json
import os
import logging
import shutil
+from tempfile import mkstemp
import tg
from pylons import app_globals as g
@@ -61,9 +62,11 @@ def bulk_export(project_shortname, tools, username, neighborhood):
log.info('Exporting %s...' % tool)
try:
path = create_export_dir(project)
- with open(os.path.join(path, '%s.json' % tool), 'w') as f:
+ temp_name = mkstemp(dir=path)[1]
+ with open(temp_name, 'w') as f:
with h.push_context(project._id):
entry_to_export.bulk_export(f)
+ os.rename(temp_name, os.path.join(path, '%s.json' % tool))
except:
log.error('Something went wrong during export of %s' % tool, exc_info=True)
not_exported_tools.append(tool)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e053432/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 0d3386b..ee9911b 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -143,6 +143,7 @@ scm.repos.tarball.url_prefix = http://localhost/
scm.repos.tarball.zip_binary = /usr/bin/zip
bulk_export_path = /tmp/bulk_export/{nbhd}/{project}
+bulk_export_filename = {project}-backup-{date:%Y-%m-%d-%H%M%S}.zip
bulk_export_download_instructions = Sample instructions for {project}
# space-separated list of tool names that are valid options
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1e053432/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index 9ce586e..2546149 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -103,6 +103,7 @@ scm.repos.tarball.root = /tmp/tarball
scm.repos.tarball.url_prefix = file://
bulk_export_path = /tmp/bulk_export/{nbhd}/{project}
+bulk_export_filename = {project}.zip
bulk_export_download_instructions = Sample instructions for {project}
support_tool_choices = wiki tickets discussion
[40/50] git commit: [#3154] merge fix conflict
Posted by jo...@apache.org.
[#3154] merge fix conflict
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/e564195a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/e564195a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/e564195a
Branch: refs/heads/cj/6530
Commit: e564195accf974e013e3123c3c25f864ef9d6c7a
Parents: 1e05343
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Aug 16 18:33:37 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:45 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/functional/test_admin.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e564195a/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 9703b76..4988a8c 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -821,7 +821,7 @@ class TestExport(TestController):
assert_not_in('Search</label> <a href="/p/test/search/">/p/test/search/</a>', r)
def test_export_page_contains_hidden_tools(self):
- with patch('allura.ext.search.search_main.SearchApp.exportable'):
+ with mock.patch('allura.ext.search.search_main.SearchApp.exportable'):
project = M.Project.query.get(shortname='test')
exportable_tools = AdminApp.exportable_tools_for(project)
tools = [t.options.mount_point for t in exportable_tools
@@ -851,7 +851,7 @@ class TestExport(TestController):
export_tasks.bulk_export.post.assert_called_once_with(
'test', [u'wiki', u'wiki2'], u'test-admin', u'Projects')
- @patch('allura.ext.admin.admin_main.export_tasks')
+ @mock.patch('allura.ext.admin.admin_main.export_tasks')
def test_export_in_progress(self, export_tasks):
p = M.Project.query.get(shortname='test')
tmpdir = os.path.join(p.bulk_export_path(), p.shortname)
@@ -890,4 +890,3 @@ class TestExport(TestController):
def test_bulk_export_path_for_nbhd(self):
project = M.Project.query.get(name='Home Project for Projects')
assert_equals(project.bulk_export_path(), '/tmp/bulk_export/p/p')
-
[48/50] git commit: [#3154] simplify zipping & cleanup
Posted by jo...@apache.org.
[#3154] simplify zipping & cleanup
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d91d964e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d91d964e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d91d964e
Branch: refs/heads/cj/6530
Commit: d91d964e24f8960fe7cd7e7d94198f4632f57a09
Parents: 7a5bf4c
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Aug 22 20:04:25 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 21:28:23 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 2 +-
Allura/allura/tasks/export_tasks.py | 29 +++++++++++------------------
Allura/allura/tests/test_tasks.py | 22 +++++++---------------
3 files changed, 19 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d91d964e/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 0e33c94..22bd228 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -653,7 +653,7 @@ class ProjectAdminController(BaseController):
flash('Export for project %s already running' % c.project.shortname, 'info')
redirect('export')
export_tasks.bulk_export.post(tools)
- flash('Export scheduled', 'ok')
+ flash('Export scheduled. You will recieve an email with download instructions when complete.', 'ok')
redirect('export')
return {
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d91d964e/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 06590021..d06105e 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -16,6 +16,7 @@
# under the License.
import os
+import os.path
import logging
import shutil
from tempfile import mkstemp
@@ -47,6 +48,7 @@ def bulk_export(tools):
def _bulk_export(project, tools, user):
export_filename = project.bulk_export_filename()
+ export_path = create_export_dir(project, export_filename)
not_exported_tools = []
for tool in tools or []:
app = project.app_instance(tool)
@@ -60,12 +62,9 @@ def _bulk_export(project, tools, user):
continue
log.info('Exporting %s...' % tool)
try:
- path = create_export_dir(project, export_filename)
- temp_name = mkstemp(dir=path)[1]
- with open(temp_name, 'w') as f:
- with h.push_context(project._id):
- app.bulk_export(f)
- os.rename(temp_name, os.path.join(path, '%s.json' % tool))
+ json_file = os.path.join(export_path, '%s.json' % tool)
+ with open(json_file, 'w') as f:
+ app.bulk_export(f)
except:
log.error('Something went wrong during export of %s' % tool, exc_info=True)
not_exported_tools.append(tool)
@@ -74,7 +73,7 @@ def _bulk_export(project, tools, user):
if tools and len(not_exported_tools) < len(tools):
# If that fails, we need to let it fail
# there won't be a valid zip file for the user to get.
- zip_and_cleanup(project, export_filename)
+ zip_and_cleanup(export_path, export_filename)
else:
log.error('Nothing to export')
return None
@@ -106,25 +105,19 @@ def create_export_dir(project, export_filename):
"""Create temporary directory for export files"""
# Name temporary directory after project shortname,
# thus zipdir() will use proper prefix inside the archive.
- tmp_dir_suffix = export_filename.split('.')[0]
+ tmp_dir_suffix = os.path.splitext(export_filename)[0]
path = os.path.join(project.bulk_export_path(), tmp_dir_suffix)
if not os.path.exists(path):
os.makedirs(path)
return path
-def zip_and_cleanup(project, export_filename):
+def zip_and_cleanup(export_path, export_filename):
"""
- Zip exported data for a given project and filename (no path).
+ Zip exported data for a given path and filename.
Copy it to proper location. Remove temporary files.
"""
- path = project.bulk_export_path()
- temp = os.path.join(path, export_filename.split('.')[0])
- zip_path_temp = os.path.join(temp, export_filename)
- zip_path = os.path.join(path, export_filename)
-
- zipdir(temp, zip_path_temp)
+ zipdir(export_path, os.path.join(os.path.dirname(export_path), export_filename))
# cleanup
- shutil.move(zip_path_temp, zip_path)
- shutil.rmtree(temp)
\ No newline at end of file
+ shutil.rmtree(export_path)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d91d964e/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 26bcb36..80ecdfa 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -344,10 +344,8 @@ class TestExportTasks(unittest.TestCase):
@mock.patch('allura.tasks.export_tasks.log')
def test_bulk_export_invalid_tool(self, log):
export_tasks.bulk_export([u'bugs', u'blog'])
- assert_equal(log.info.call_count, 2)
- assert_equal(log.info.call_args_list, [
- mock.call('Can not load app for bugs mount point. Skipping.'),
- mock.call('Can not load app for blog mount point. Skipping.')])
+ log.info.assert_any_call('Can not load app for bugs mount point. Skipping.')
+ log.info.assert_any_call('Can not load app for blog mount point. Skipping.')
@mock.patch('allura.tasks.export_tasks.log')
@mock.patch('allura.tasks.export_tasks.M.Project.app_instance')
@@ -357,10 +355,8 @@ class TestExportTasks(unittest.TestCase):
def test_bulk_export_not_exportable_tool(self, mail_tasks, app, log):
app.return_value.exportable = False
export_tasks.bulk_export([u'bugs', u'blog'])
- assert_equal(log.info.call_count, 2)
- assert_equal(log.info.call_args_list, [
- mock.call('Tool bugs is not exportable. Skipping.'),
- mock.call('Tool blog is not exportable. Skipping.')])
+ log.info.assert_any_call('Tool bugs is not exportable. Skipping.')
+ log.info.assert_any_call('Tool blog is not exportable. Skipping.')
@mock.patch('allura.model.project.Project.__json__')
@mock.patch('allura.tasks.export_tasks.shutil')
@@ -371,15 +367,12 @@ class TestExportTasks(unittest.TestCase):
def test_bulk_export(self, log, wiki_bulk_export, zipdir, shutil, project_json):
M.MonQTask.query.remove()
export_tasks.bulk_export([u'wiki'])
- assert_equal(log.info.call_count, 1)
- assert_equal(log.info.call_args_list, [
- mock.call('Exporting wiki...')])
+ log.info.assert_any_call('Exporting wiki...')
wiki_bulk_export.assert_called_once()
project_json.assert_called_once()
temp = '/tmp/bulk_export/p/test/test'
zipfn = '/tmp/bulk_export/p/test/test.zip'
zipdir.assert_caled_with(temp, temp + '/test.zip')
- shutil.move.assert_called_once_with(temp + '/test.zip', zipfn)
shutil.rmtree.assert_called_once_with(temp)
# check notification
M.MonQTask.run_ready()
@@ -403,12 +396,11 @@ class TestExportTasks(unittest.TestCase):
@onlyif(os.path.exists(tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')), 'zip binary is missing')
def test_zip_and_cleanup(self):
project = M.Project.query.get(shortname='test')
- export_path = project.bulk_export_path()
export_filename = project.bulk_export_filename()
path = export_tasks.create_export_dir(project, export_filename)
- export_tasks.zip_and_cleanup(project, export_filename)
+ export_tasks.zip_and_cleanup(path, export_filename)
assert not os.path.exists(path)
- assert os.path.exists(os.path.join(export_path, 'test.zip'))
+ assert os.path.exists(os.path.join(project.bulk_export_path(), 'test.zip'))
def test_bulk_export_status(self):
assert_equal(c.project.bulk_export_status(), None)
[19/50] git commit: [#3154] ticket:393 Fix test after merge
Posted by jo...@apache.org.
[#3154] ticket:393 Fix test after merge
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/88834803
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/88834803
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/88834803
Branch: refs/heads/cj/6530
Commit: 88834803601ea327ae20c7752f543445595f6d86
Parents: b2ae1d0
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Jul 24 13:32:26 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:42 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/test_tasks.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/88834803/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 60a1abc..06d4ede 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -363,7 +363,7 @@ class TestExportTasks(unittest.TestCase):
export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin')
assert_equal(log.info.call_count, 2)
assert_equal(log.info.call_args_list, [
- mock.call('Tool urls is not exportable. Skipping.'),
+ mock.call('Tool bugs is not exportable. Skipping.'),
mock.call('Tool blog is not exportable. Skipping.')])
@mock.patch('allura.tasks.export_tasks.shutil')
[11/50] git commit: [#3153] ticket:389 finished tickets with posts
export
Posted by jo...@apache.org.
[#3153] ticket:389 finished tickets with posts export
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/208d57f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/208d57f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/208d57f2
Branch: refs/heads/cj/6530
Commit: 208d57f23f7077fbd5453940743fb21fb8f7cf38
Parents: 21ed41e
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Jul 23 17:39:23 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:41 2013 +0000
----------------------------------------------------------------------
ForgeTracker/forgetracker/tests/test_app.py | 15 +++++++++++----
ForgeTracker/forgetracker/tracker_main.py | 1 +
2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/208d57f2/ForgeTracker/forgetracker/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
index 9c7e61e..e99948b 100644
--- a/ForgeTracker/forgetracker/tests/test_app.py
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -35,13 +35,20 @@ class TestBulkExport(TrackerTestController):
self.project = M.Project.query.get(shortname='test')
self.tracker = self.project.app_instance('bugs')
self.new_ticket(summary='foo', _milestone='1.0')
+ self.new_ticket(summary='bar', _milestone='1.0')
+ ticket = TM.Ticket.query.find(dict(summary='foo')).first()
+ ticket.discussion_thread.add_post(text='silly comment')
def test_bulk_export(self):
f = tempfile.TemporaryFile()
self.tracker.bulk_export(f)
f.seek(0)
tracker = json.loads(f.read())
- #tickets = sorted(tracker['tickets'], key=operator.itemgetter('title'))
- tickets = tracker['tickets']
- print tickets
- assert_equal(len(tickets), 1)
+ tickets = sorted(tracker['tickets'], key=operator.itemgetter('summary'))
+ assert_equal(len(tickets), 2)
+ ticket_foo = tickets[1]
+ assert_equal(ticket_foo['summary'], 'foo')
+ assert_equal(ticket_foo['custom_fields']['_milestone'], '1.0')
+ posts_foo = ticket_foo['discussion_thread']['posts']
+ assert_equal(len(posts_foo), 1)
+ assert_equal(posts_foo[0]['text'], 'silly comment')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/208d57f2/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index ff540c3..4a622c5 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -206,6 +206,7 @@ class ForgeTrackerApp(Application):
schema.OneOf('NewTicketsOnly', 'AllTicketChanges',
'NewPublicTicketsOnly', 'AllPublicTicketChanges'), None)
]
+ exportable = True
searchable=True
tool_label='Tickets'
tool_description="""
[38/50] git commit: [#3154] ticket:411 config bool refactor
Posted by jo...@apache.org.
[#3154] ticket:411 config bool refactor
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b1545256
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b1545256
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b1545256
Branch: refs/heads/cj/6530
Commit: b1545256cd9ecc3288d929ab1258a0533a1a95e6
Parents: e5bcf01
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Thu Aug 15 16:39:59 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:45 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b1545256/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 9cc0f28..f763258 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -142,7 +142,7 @@ class AdminApp(Application):
SitemapEntry('Categorization', admin_url+'trove')
]
links.append(SitemapEntry('Tools', admin_url+'tools'))
- if config.get('bulk_export_enabled', 'true') == 'true':
+ if asbool(config.get('bulk_export_enabled', True)):
links.append(SitemapEntry('Export', admin_url + 'export'))
if c.project.is_root and has_access(c.project, 'admin')():
links.append(SitemapEntry('User Permissions', admin_url+'groups/'))
@@ -636,7 +636,7 @@ class ProjectAdminController(BaseController):
@expose('jinja:allura.ext.admin:templates/export.html')
def export(self, tools=None):
- if config.get('bulk_export_enabled', 'true') != 'true':
+ if not asbool(config.get('bulk_export_enabled', True)):
redirect('.')
exportable_tools = AdminApp.exportable_tools_for(c.project)
if request.method == 'POST':
[29/50] git commit: [#3154] avoid doing an extra count() query or
storing all items in memory
Posted by jo...@apache.org.
[#3154] avoid doing an extra count() query or storing all items in memory
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/8072d30e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/8072d30e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/8072d30e
Branch: refs/heads/cj/6530
Commit: 8072d30ef1faf24b864894c04111d85da0f89f97
Parents: 818b395
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Aug 6 15:37:20 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:44 2013 +0000
----------------------------------------------------------------------
ForgeBlog/forgeblog/main.py | 5 ++---
ForgeDiscussion/forgediscussion/forum_main.py | 7 +++----
ForgeTracker/forgetracker/tracker_main.py | 7 +++----
ForgeWiki/forgewiki/wiki_main.py | 7 +++----
4 files changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8072d30e/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index e6da34f..6f344cb 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -193,11 +193,10 @@ class ForgeBlogApp(Application):
def bulk_export(self, f):
f.write('{"posts": [')
posts = BM.BlogPost.query.find(dict(app_config_id=self.config._id)).sort('timestamp', pymongo.DESCENDING)
- count = len(posts)
for i, post in enumerate(posts):
- json.dump(post, f, cls=jsonify.GenericJSON, indent=2)
- if i < (count - 1):
+ if i > 0:
f.write(',')
+ json.dump(post, f, cls=jsonify.GenericJSON, indent=2)
f.write(']}')
class RootController(BaseController, FeedController):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8072d30e/ForgeDiscussion/forgediscussion/forum_main.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index bf1835d..a91508d 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -219,12 +219,11 @@ class ForgeDiscussionApp(Application):
def bulk_export(self, f):
f.write('{"forums": [')
- forums = DM.Forum.query.find(dict(app_config_id=self.config._id)).sort('mod_date', pymongo.DESCENDING).all()
- count = len(forums)
+ forums = DM.Forum.query.find(dict(app_config_id=self.config._id)).sort('mod_date', pymongo.DESCENDING)
for i, forum in enumerate(forums):
- json.dump(forum, f, cls=jsonify.GenericJSON, indent=2)
- if i < (count - 1):
+ if i > 0:
f.write(',')
+ json.dump(forum, f, cls=jsonify.GenericJSON, indent=2)
f.write(']}')
class ForumAdminController(DefaultAdminController):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8072d30e/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 4ee0e74..c8e728c 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -412,12 +412,11 @@ class ForgeTrackerApp(Application):
f.write('{"tickets": [')
tickets = TM.Ticket.query.find(dict(
app_config_id=self.config._id,
- deleted=False)).all()
- count = len(tickets)
+ deleted=False))
for i, ticket in enumerate(tickets):
- json.dump(ticket, f, cls=jsonify.GenericJSON, indent=2)
- if i < (count - 1):
+ if i > 0:
f.write(',')
+ json.dump(ticket, f, cls=jsonify.GenericJSON, indent=2)
f.write('],\n"tracker_config":')
json.dump(self.config, f, cls=jsonify.GenericJSON, indent=2)
f.write(',\n"milestones":')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8072d30e/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index f0b85a7..5fecbb2 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -291,12 +291,11 @@ The wiki uses [Markdown](%s) syntax.
f.write('{"pages": [')
pages = WM.Page.query.find(dict(
app_config_id=self.config._id,
- deleted=False)).all()
- count = len(pages)
+ deleted=False))
for i, page in enumerate(pages):
- json.dump(page, f, cls=jsonify.GenericJSON, indent=2)
- if i < (count - 1):
+ if i > 0:
f.write(',')
+ json.dump(page, f, cls=jsonify.GenericJSON, indent=2)
f.write(']}')
[20/50] git commit: [#3154] add & update project json API
Posted by jo...@apache.org.
[#3154] add & update project json API
* add screenshots
* fix screenshot url encoding on screenshot admin page
* add trove categories
* add a few individual fields
* rename fields to match their usage better
* remove download field since it's SourceForge-specific
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/20955bde
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/20955bde
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/20955bde
Branch: refs/heads/cj/6530
Commit: 20955bde78b1a4d03b0f80119827a8947903a335
Parents: c71f754
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Aug 1 15:35:24 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:43 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/auth.py | 2 +-
Allura/allura/model/project.py | 52 +++++++++++++++++---
.../templates/widgets/project_screenshots.html | 2 +-
Allura/allura/tests/functional/test_rest.py | 11 ++---
4 files changed, 53 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20955bde/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index c8964f3..fb58ce9 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -702,7 +702,7 @@ class User(MappedClass, ActivityNode, ActivityObject):
return dict(
username=self.username,
name=self.display_name,
- url=self.url(),
+ url=h.absurl(self.url()),
)
class OldProjectRole(MappedClass):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20955bde/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 941b360..2258c18 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -20,6 +20,7 @@ import logging
from collections import Counter, OrderedDict
from datetime import datetime
from copy import deepcopy
+import urllib
from tg import config
from pylons import tmpl_context as c, app_globals as g
@@ -137,6 +138,14 @@ class TroveCategory(MappedClass):
crumbs.append((trove.fullname, url))
return crumbs
+ def __json__(self):
+ return dict(
+ id=self.trove_cat_id,
+ shortname=self.shortname,
+ fullname=self.fullname,
+ fullpath=self.fullpath,
+ )
+
class ProjectMapperExtension(MapperExtension):
def after_insert(self, obj, st, sess):
g.zarkov_event('project_create', project=obj)
@@ -250,6 +259,21 @@ class Project(MappedClass, ActivityNode, ActivityObject):
def troves_by_type(self, trove_type):
return TroveCategory.query.find({'_id':{'$in':getattr(self,'trove_%s' % trove_type)}}).all()
+ def all_troves(self):
+ '''
+ Returns a dict of human-readable root troves => [categories]
+ '''
+ troves = {}
+ for attr in dir(self):
+ if attr.startswith('trove_'):
+ trove_type = attr.replace('trove_','')
+ nice_name = dict(
+ natlanguage='translation',
+ root_database='database',
+ ).get(trove_type, trove_type)
+ troves[nice_name] = self.troves_by_type(trove_type)
+ return troves
+
def get_tool_data(self, tool, key, default=None):
return self.tool_data.get(tool, {}).get(key, default)
@@ -839,17 +863,33 @@ class Project(MappedClass, ActivityNode, ActivityObject):
def __json__(self):
return dict(
- name=self.shortname,
- title=self.name,
+ shortname=self.shortname,
+ name=self.name,
_id=self._id,
+ url=h.absurl(self.url()),
private=self.private,
short_description=self.short_description,
- description=self.description,
- download_page=self.best_download_url(),
- preferred_support=self.support_page_url,
+ summary=self.summary,
+ external_homepage=self.external_homepage,
+ socialnetworks=self.socialnetworks,
+ status=self.removal or 'active',
+ moved_to_url=self.moved_to_url,
+ preferred_support_tool=self.support_page,
+ preferred_support_url=self.support_page_url,
developers=self.users_with_role('Developer'),
tools=[dict(name=t.tool_name, mount_point=t.options.mount_point, label=t.options.mount_label)
- for t in self.app_configs if h.has_access(t, 'read')]
+ for t in self.app_configs if h.has_access(t, 'read')],
+ labels=self.labels,
+ categories=self.all_troves(),
+ icon_url=h.absurl(self.url() + 'icon') if self.icon else None,
+ screenshots = [
+ dict(
+ url = h.absurl(self.url() + 'screenshot/' + urllib.quote(ss.filename)),
+ thumbnail_url = h.absurl(self.url() + 'screenshot/' + urllib.quote(ss.filename) + '/thumb'),
+ caption = ss.caption,
+ )
+ for ss in self.get_screenshots()
+ ]
)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20955bde/Allura/allura/templates/widgets/project_screenshots.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/project_screenshots.html b/Allura/allura/templates/widgets/project_screenshots.html
index 01d9849..7d3d338 100644
--- a/Allura/allura/templates/widgets/project_screenshots.html
+++ b/Allura/allura/templates/widgets/project_screenshots.html
@@ -24,7 +24,7 @@
{% for ss in screenshots %}
<div data-ss-id="{{ ss._id }}" class="screenshot">
<div class="image">
- <a href="{{project.url()}}screenshot/{{ss.filename}}"><img src="{{project.url()}}screenshot/{{ss.filename}}/thumb" alt="Screenshot thumbnail"/></a>
+ <a href="{{project.url()}}screenshot/{{h.urlquote(ss.filename)}}"><img src="{{project.url()}}screenshot/{{h.urlquote(ss.filename)}}/thumb" alt="Screenshot thumbnail"/></a>
{% if not edit %}
<br>
{{ss.caption}}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/20955bde/Allura/allura/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_rest.py b/Allura/allura/tests/functional/test_rest.py
index 0278666..0977f26 100644
--- a/Allura/allura/tests/functional/test_rest.py
+++ b/Allura/allura/tests/functional/test_rest.py
@@ -74,14 +74,13 @@ class TestRestHome(TestRestApiBase):
def test_project_data(self):
r = self.api_get('/rest/p/test/')
- assert_equal(r.json['name'], 'test')
- assert_equal(r.json['title'], 'Test Project')
- assert_equal(r.json['description'], 'You can edit this description in the admin page')
+ assert_equal(r.json['shortname'], 'test')
+ assert_equal(r.json['name'], 'Test Project')
assert_equal(len(r.json['developers']), 1)
admin_dev = r.json['developers'][0]
assert_equal(admin_dev['username'], 'test-admin')
assert_equal(admin_dev['name'], 'Test Admin')
- assert_equal(admin_dev['url'], '/u/test-admin/')
+ assert_equal(admin_dev['url'], 'http://localhost:80/u/test-admin/')
@td.with_tool('test', 'Tickets', 'bugs')
@td.with_tool('test', 'Tickets', 'private-bugs')
@@ -95,14 +94,14 @@ class TestRestHome(TestRestApiBase):
# admin sees both 'Tickets' tools
r = self.api_get('/rest/p/test/')
- assert_equal(r.json['name'], 'test')
+ assert_equal(r.json['shortname'], 'test')
tool_mounts = [t['mount_point'] for t in r.json['tools']]
assert_in('bugs', tool_mounts)
assert_in('private-bugs', tool_mounts)
# anonymous sees only non-private tool
r = self.app.get('/rest/p/test/', extra_environ={'username': '*anonymous'})
- assert_equal(r.json['name'], 'test')
+ assert_equal(r.json['shortname'], 'test')
tool_mounts = [t['mount_point'] for t in r.json['tools']]
assert_in('bugs', tool_mounts)
assert_not_in('private-bugs', tool_mounts)
[31/50] git commit: [#3154] ticket:409 fixed bulk export for nbhd and
user projects
Posted by jo...@apache.org.
[#3154] ticket:409 fixed bulk export for nbhd and user projects
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/526063a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/526063a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/526063a5
Branch: refs/heads/cj/6530
Commit: 526063a5c67058d8baba83a8e0975cb1ba99984b
Parents: cf72c2e
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Tue Aug 13 18:15:28 2013 +0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:44 2013 +0000
----------------------------------------------------------------------
Allura/allura/ext/admin/admin_main.py | 2 +-
Allura/allura/model/project.py | 18 ++++++++++++++++--
Allura/allura/tasks/export_tasks.py | 5 +++--
Allura/allura/tests/functional/test_admin.py | 23 +++++++++++++++++++++--
Allura/allura/tests/test_tasks.py | 10 +++++-----
5 files changed, 46 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/526063a5/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 0dbc5a5..d1f98da 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -649,7 +649,7 @@ class ProjectAdminController(BaseController):
if c.project.bulk_export_status() == 'busy':
flash('Export for project %s already running' % c.project.shortname, 'info')
redirect('export')
- export_tasks.bulk_export.post(c.project.shortname, tools, c.user.username)
+ export_tasks.bulk_export.post(c.project.shortname, tools, c.user.username, c.project.neighborhood.name)
flash('Export scheduled', 'ok')
redirect('export')
return {
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/526063a5/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 1b21d37..18bd934 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -846,12 +846,26 @@ class Project(MappedClass, ActivityNode, ActivityObject):
))
def bulk_export_path(self):
+ shortname = self.shortname
+ if self.is_nbhd_project:
+ shortname = self.url().strip('/')
+ elif self.is_user_project:
+ shortname = self.shortname.split('/')[1]
+ elif not self.is_root:
+ shortname = self.shortname.split('/')[0]
return config['bulk_export_path'].format(
nbhd=self.neighborhood.url_prefix.strip('/'),
- project=self.shortname)
+ project=shortname)
def bulk_export_filename(self):
- return '%s.zip' % self.shortname
+ shortname = self.shortname
+ if self.is_nbhd_project:
+ shortname = self.url().strip('/')
+ elif self.is_user_project:
+ shortname = self.shortname.split('/')[1]
+ elif not self.is_root:
+ shortname = self.shortname.split('/')[1]
+ return '%s.zip' % shortname
def bulk_export_status(self):
fn = os.path.join(self.bulk_export_path(), self.bulk_export_filename())
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/526063a5/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 9933e26..0eb99e0 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -34,8 +34,9 @@ log = logging.getLogger(__name__)
@task
-def bulk_export(project_shortname, tools, username):
- project = M.Project.query.get(shortname=project_shortname)
+def bulk_export(project_shortname, tools, username, neighborhood):
+ neighborhood = M.Neighborhood.query.get(name=neighborhood)
+ project = M.Project.query.get(shortname=project_shortname, neighborhood_id=neighborhood._id)
if not project:
log.error('Project %s not found' % project_shortname)
return
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/526063a5/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 4fd0d19..9ee232f 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -825,14 +825,14 @@ class TestExport(TestController):
r = self.app.post('/admin/export', {'tools': u'wiki'})
assert_in('ok', self.webflash(r))
export_tasks.bulk_export.post.assert_called_once_with(
- 'test', [u'wiki'], u'test-admin')
+ 'test', [u'wiki'], u'test-admin', u'Projects')
@mock.patch('allura.ext.admin.admin_main.export_tasks')
def test_selected_multiple_tools(self, export_tasks):
r = self.app.post('/admin/export', {'tools': [u'wiki', u'wiki2']})
assert_in('ok', self.webflash(r))
export_tasks.bulk_export.post.assert_called_once_with(
- 'test', [u'wiki', u'wiki2'], u'test-admin')
+ 'test', [u'wiki', u'wiki2'], u'test-admin', u'Projects')
@patch('allura.ext.admin.admin_main.export_tasks')
def test_export_in_progress(self, export_tasks):
@@ -855,3 +855,22 @@ class TestExport(TestController):
r = self.app.get('/admin/export')
assert_in('<h2>Careful!</h2>', r)
shutil.rmtree(p.bulk_export_path(), ignore_errors=True)
+
+ @td.with_user_project('test-user')
+ def test_bulk_export_path_for_user_project(self):
+ project = M.Project.query.get(shortname='u/test-user')
+ assert_equals(project.bulk_export_path(), '/tmp/bulk_export/u/test-user')
+
+ @td.with_user_project('test-user')
+ def test_bulk_export_filename_for_user_project(self):
+ project = M.Project.query.get(shortname='u/test-user')
+ assert_equals(project.bulk_export_filename(), 'test-user.zip')
+
+ def test_bulk_export_filename_for_nbhd(self):
+ project = M.Project.query.get(name='Home Project for Projects')
+ assert_equals(project.bulk_export_filename(), 'p.zip')
+
+ def test_bulk_export_path_for_nbhd(self):
+ project = M.Project.query.get(name='Home Project for Projects')
+ assert_equals(project.bulk_export_path(), '/tmp/bulk_export/p/p')
+
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/526063a5/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index c772253..a1e09c3 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -342,12 +342,12 @@ class TestExportTasks(unittest.TestCase):
@mock.patch('allura.tasks.export_tasks.log')
def test_bulk_export_invalid_project(self, log):
- export_tasks.bulk_export('bad', [u'wiki'], 'test-admin')
+ export_tasks.bulk_export('bad', [u'wiki'], 'test-admin', 'Projects')
log.error.assert_called_once_with('Project bad not found')
@mock.patch('allura.tasks.export_tasks.log')
def test_bulk_export_invalid_tool(self, log):
- export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin')
+ export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin', 'Projects')
assert_equal(log.info.call_count, 2)
assert_equal(log.info.call_args_list, [
mock.call('Can not load app for bugs mount point. Skipping.'),
@@ -360,7 +360,7 @@ class TestExportTasks(unittest.TestCase):
@td.with_tool('test', 'Blog', 'blog')
def test_bulk_export_not_exportable_tool(self, mail_tasks, app, log):
app.return_value.exportable = False
- export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin')
+ export_tasks.bulk_export('test', [u'bugs', u'blog'], 'test-admin', 'Projects')
assert_equal(log.info.call_count, 2)
assert_equal(log.info.call_args_list, [
mock.call('Tool bugs is not exportable. Skipping.'),
@@ -374,7 +374,7 @@ class TestExportTasks(unittest.TestCase):
@td.with_wiki
def test_bulk_export(self, log, wiki_bulk_export, zipdir, shutil, project_json):
M.MonQTask.query.remove()
- export_tasks.bulk_export('test', [u'wiki'], 'test-admin')
+ export_tasks.bulk_export('test', [u'wiki'], 'test-admin', 'Projects')
assert_equal(log.info.call_count, 1)
assert_equal(log.info.call_args_list, [
mock.call('Exporting wiki...')])
@@ -403,7 +403,7 @@ class TestExportTasks(unittest.TestCase):
project = M.Project.query.get(shortname='test')
export_tasks.create_export_dir(project)
assert_equal(project.bulk_export_status(), 'busy')
- export_tasks.bulk_export('test', [u'wiki'], 'test-admin')
+ export_tasks.bulk_export('test', [u'wiki'], 'test-admin', 'Projects')
log.info.assert_called_once_with('Another export is running for project test. Skipping.')
assert_equal(wiki_bulk_export.call_count, 0)
[06/50] git commit: [#3153] ticket:389 added milestones to tracker
bulk_export
Posted by jo...@apache.org.
[#3153] ticket:389 added milestones to tracker bulk_export
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/59d60f6e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/59d60f6e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/59d60f6e
Branch: refs/heads/cj/6530
Commit: 59d60f6e6387d4f171a16fa4bb4b8a047780388a
Parents: 68077e9
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Jul 23 20:09:29 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:41 2013 +0000
----------------------------------------------------------------------
ForgeTracker/forgetracker/tests/test_app.py | 6 ++++-
ForgeTracker/forgetracker/tracker_main.py | 31 +++++++++++++++---------
2 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/59d60f6e/ForgeTracker/forgetracker/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
index 7437e4d..a718885 100644
--- a/ForgeTracker/forgetracker/tests/test_app.py
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -35,7 +35,7 @@ class TestBulkExport(TrackerTestController):
self.project = M.Project.query.get(shortname='test')
self.tracker = self.project.app_instance('bugs')
self.new_ticket(summary='foo', _milestone='1.0')
- self.new_ticket(summary='bar', _milestone='1.0')
+ self.new_ticket(summary='bar', _milestone='2.0')
ticket = TM.Ticket.query.find(dict(summary='foo')).first()
ticket.discussion_thread.add_post(text='silly comment')
@@ -59,3 +59,7 @@ class TestBulkExport(TrackerTestController):
assert_true('options' in tracker_config.keys())
assert_true('acl' in tracker_config.keys())
assert_equal(tracker_config['options']['mount_point'], 'bugs')
+
+ milestones = sorted(tracker['milestones'], key=operator.itemgetter('name'))
+ assert_equal(milestones[0]['name'], '1.0')
+ assert_equal(milestones[1]['name'], '2.0')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/59d60f6e/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 5c574e3..1880cd8 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -420,12 +420,30 @@ class ForgeTrackerApp(Application):
f.write(',')
f.write('], "tracker_config":')
json.dump(self.config, f, cls=jsonify.GenericJSON)
+ f.write(', "milestones":')
+ milestones = self.milestones
+ json.dump(milestones, f, cls=jsonify.GenericJSON)
f.write('}')
@property
def bins(self):
return TM.Bin.query.find(dict(app_config_id=self.config._id)).sort('summary').all()
+ @property
+ def milestones(self):
+ milestones = []
+ for fld in self.globals.milestone_fields:
+ if fld.name == '_milestone':
+ for m in fld.milestones:
+ d = self.globals.milestone_count('%s:%s' % (fld.name, m.name))
+ milestones.append(dict(
+ name=m.name,
+ due_date=m.get('due_date'),
+ description=m.get('description'),
+ complete=m.get('complete'),
+ total=d['hits'],
+ closed=d['closed']))
+ return milestones
### Controllers ###
@@ -614,19 +632,8 @@ class RootController(BaseController, FeedController):
@expose('jinja:forgetracker:templates/tracker/milestones.html')
def milestones(self, **kw):
require_access(c.app, 'configure')
- milestones = []
c.date_field = W.date_field
- for fld in c.app.globals.milestone_fields:
- if fld.name == '_milestone':
- for m in fld.milestones:
- d = c.app.globals.milestone_count('%s:%s' % (fld.name, m.name))
- milestones.append(dict(
- name=m.name,
- due_date=m.get('due_date'),
- description=m.get('description'),
- complete=m.get('complete'),
- total=d['hits'],
- closed=d['closed']))
+ milestones = c.app.milestones
return dict(milestones=milestones)
@without_trailing_slash
[49/50] git commit: [#3154] fix test;
behavior changed due to more immediate error raising in monqtask
during tests
Posted by jo...@apache.org.
[#3154] fix test; behavior changed due to more immediate error raising in monqtask during tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/0fb6390f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0fb6390f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0fb6390f
Branch: refs/heads/cj/6530
Commit: 0fb6390f19fdfeff5ac51864f7070f8507e1037b
Parents: d91d964
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Aug 22 22:21:57 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 22:21:57 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/decorators.py | 9 +++++++--
Allura/allura/tests/test_commands.py | 7 +++----
2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0fb6390f/Allura/allura/tests/decorators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/decorators.py b/Allura/allura/tests/decorators.py
index 8c9e4c9..dd9fdf1 100644
--- a/Allura/allura/tests/decorators.py
+++ b/Allura/allura/tests/decorators.py
@@ -87,16 +87,21 @@ with_wiki = with_tool('test', 'Wiki', 'wiki')
with_url = with_tool('test', 'ShortUrl', 'url')
class raises(object):
- 'test helper in the form of a context manager, to assert that something raises an exception'
+ '''
+ Test helper in the form of a context manager, to assert that something raises an exception.
+ After completion, the 'exc' attribute can be used to do further inspection of the exception
+ '''
def __init__(self, ExcType):
self.ExcType = ExcType
+ self.exc = None
def __enter__(self):
- pass
+ return self
def __exit__(self, exc_type, exc_val, exc_t):
if exc_type:
+ self.exc = exc_val
if issubclass(exc_type, self.ExcType):
# ok
return True
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0fb6390f/Allura/allura/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_commands.py b/Allura/allura/tests/test_commands.py
index 09dc3b6..b290380 100644
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -344,10 +344,9 @@ class TestBackgroundCommand(object):
def test_invalid_args(self):
M.MonQTask.query.remove()
show_models.ReindexCommand.post('--invalid-option')
- M.MonQTask.run_ready()
- task = M.MonQTask.query.get(task_name=self.task_name)
- assert_equal(task.state, 'error')
- assert_in('Error parsing args', task.result)
+ with td.raises(Exception) as e:
+ M.MonQTask.run_ready()
+ assert_in('Error parsing args', str(e.exc))
class TestReindexCommand(object):
[34/50] git commit: [#3154] ticket#411 removed sort in export queries
Posted by jo...@apache.org.
[#3154] ticket#411 removed sort in export queries
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1c24bb70
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1c24bb70
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1c24bb70
Branch: refs/heads/cj/6530
Commit: 1c24bb70d92e73e180e8f772c6cb5ff024e3d062
Parents: 526063a
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Aug 13 14:41:00 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:44 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/discuss.py | 7 ++++---
ForgeBlog/forgeblog/main.py | 2 +-
ForgeBlog/forgeblog/tests/test_app.py | 1 +
ForgeDiscussion/forgediscussion/forum_main.py | 2 +-
ForgeDiscussion/forgediscussion/tests/test_app.py | 2 +-
5 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c24bb70/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index ec5ccdc..057bb97 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -65,8 +65,8 @@ class Discussion(Artifact, ActivityObject):
name=self.name,
description=self.description,
threads=[t.__json__() for t in self.thread_class().query.find(
- dict(discussion_id=self._id)).sort(
- 'last_post_date', pymongo.DESCENDING)])
+ dict(discussion_id=self._id))]
+ )
@property
def activity_name(self):
@@ -172,7 +172,8 @@ class Thread(Artifact, ActivityObject):
url=h.absurl(attach.url())) for attach in p.attachments])
for p in self.post_class().query.find(
dict(discussion_id=self.discussion_id, thread_id=self._id, status='ok')
- ).sort('timestamp', pymongo.DESCENDING)])
+ )]
+ )
@property
def activity_name(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c24bb70/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 6f344cb..3abf4f0 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -192,7 +192,7 @@ class ForgeBlogApp(Application):
def bulk_export(self, f):
f.write('{"posts": [')
- posts = BM.BlogPost.query.find(dict(app_config_id=self.config._id)).sort('timestamp', pymongo.DESCENDING)
+ posts = BM.BlogPost.query.find(dict(app_config_id=self.config._id))
for i, post in enumerate(posts):
if i > 0:
f.write(',')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c24bb70/ForgeBlog/forgeblog/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/test_app.py b/ForgeBlog/forgeblog/tests/test_app.py
index 622dccf..7427b9b 100644
--- a/ForgeBlog/forgeblog/tests/test_app.py
+++ b/ForgeBlog/forgeblog/tests/test_app.py
@@ -56,6 +56,7 @@ class TestBulkExport(object):
blog.bulk_export(f)
f.seek(0)
blog = json.loads(f.read())
+ blog['posts'] = sorted(blog['posts'], key=lambda x: x['title'], reverse=True)
assert_equal(blog['posts'][0]['title'], 'Test2 title')
assert_equal(blog['posts'][0]['text'], 'test2 post')
assert_equal(blog['posts'][1]['title'], 'Test title')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c24bb70/ForgeDiscussion/forgediscussion/forum_main.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index a91508d..54c4bef 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -219,7 +219,7 @@ class ForgeDiscussionApp(Application):
def bulk_export(self, f):
f.write('{"forums": [')
- forums = DM.Forum.query.find(dict(app_config_id=self.config._id)).sort('mod_date', pymongo.DESCENDING)
+ forums = DM.Forum.query.find(dict(app_config_id=self.config._id))
for i, forum in enumerate(forums):
if i > 0:
f.write(',')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1c24bb70/ForgeDiscussion/forgediscussion/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/test_app.py b/ForgeDiscussion/forgediscussion/tests/test_app.py
index d54ab5a..bc9dcb1 100644
--- a/ForgeDiscussion/forgediscussion/tests/test_app.py
+++ b/ForgeDiscussion/forgediscussion/tests/test_app.py
@@ -36,7 +36,7 @@ class TestBulkExport(TestDiscussionApiBase):
discussion.bulk_export(f)
f.seek(0)
discussion = json.loads(f.read())
- forums = discussion['forums']
+ forums = sorted(discussion['forums'], key=lambda x: x['name'])
assert_equal(forums[0]['shortname'], u'general')
assert_equal(forums[0]['description'], u'Forum about anything you want to talk about.')
[25/50] git commit: [#3154] tweak bulk export email text & formatting
Posted by jo...@apache.org.
[#3154] tweak bulk export email text & formatting
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/6ee0e0d6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6ee0e0d6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6ee0e0d6
Branch: refs/heads/cj/6530
Commit: 6ee0e0d68d6b3b409cddc90dd14d85bdeef7a008
Parents: 20955bd
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Aug 1 15:37:24 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:43 2013 +0000
----------------------------------------------------------------------
Allura/allura/templates/mail/bulk_export.html | 14 ++++++++------
Allura/allura/tests/test_tasks.py | 4 ++--
2 files changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6ee0e0d6/Allura/allura/templates/mail/bulk_export.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/mail/bulk_export.html b/Allura/allura/templates/mail/bulk_export.html
index 95ade78..e8aded1 100644
--- a/Allura/allura/templates/mail/bulk_export.html
+++ b/Allura/allura/templates/mail/bulk_export.html
@@ -17,20 +17,22 @@
under the License.
#}
-Bulk export for project {{ project.shortname }} is completed.
+The bulk export for project {{ project.shortname }} is completed.
-Following tools was exported:
-{% for tool in tools %}
+{% if tools %}
+The following tools were exported:
+{% for tool in tools -%}
- {{ tool }}
{% endfor %}
+{% endif %}
{% if not_exported_tools %}
-Following tools was not exported:
-{% for tool in not_exported_tools %}
+The following tools were not exported:
+{% for tool in not_exported_tools -%}
- {{ tool }}
{% endfor %}
{% endif %}
-Follow instructions below to get exported data.
+Follow the instructions below to get your exported data.
{{ instructions }}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6ee0e0d6/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index cd10683..c772253 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -392,8 +392,8 @@ class TestExportTasks(unittest.TestCase):
assert_equal(len(tasks), 1)
assert_equal(tasks[0].kwargs['subject'], 'Bulk export for project test completed')
text = tasks[0].kwargs['text']
- assert_in('Bulk export for project test is completed.', text)
- assert_in('Following tools was exported:\n\n- wiki', text)
+ assert_in('The bulk export for project test is completed.', text)
+ assert_in('The following tools were exported:\n- wiki', text)
assert_in('Sample instructions for test', text)
@mock.patch('forgewiki.wiki_main.ForgeWikiApp.bulk_export')
[50/50] git commit: [#6530] Improved error handling on import_tool
task
Posted by jo...@apache.org.
[#6530] Improved error handling on import_tool task
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/c6ffac86
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c6ffac86
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c6ffac86
Branch: refs/heads/cj/6530
Commit: c6ffac86b56191b328ccbd860b045eff3a68f719
Parents: 0fb6390
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Aug 22 20:59:59 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Fri Aug 23 16:57:48 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/helpers.py | 6 ++++
Allura/allura/tests/test_helpers.py | 34 ++++++++++++++++++++
ForgeImporters/forgeimporters/base.py | 18 +++++++++--
ForgeImporters/forgeimporters/google/tracker.py | 3 ++
.../forgeimporters/tests/google/test_tracker.py | 14 ++++++++
.../forgeimporters/tests/test_base.py | 20 +++++++++++-
.../forgeimporters/trac/tests/test_tickets.py | 33 +++++++++++++++----
ForgeImporters/forgeimporters/trac/tickets.py | 31 ++++++++++--------
8 files changed, 136 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c6ffac86/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 8095f79..2a4614f 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -214,6 +214,12 @@ def _make_xs(X, ids):
result = (results.get(i) for i in ids)
return (r for r in result if r is not None)
+def make_app_admin_only(app):
+ from allura.model.auth import ProjectRole
+ admin_role = ProjectRole.by_name('Admin', app.project)
+ for ace in [ace for ace in app.acl if ace.role_id != admin_role._id]:
+ app.acl.remove(ace)
+
@contextmanager
def push_config(obj, **kw):
saved_attrs = {}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c6ffac86/Allura/allura/tests/test_helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 4a0b80d..fb81224 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -25,10 +25,13 @@ from pylons import tmpl_context as c
from nose.tools import eq_, assert_equals
from IPython.testing.decorators import skipif, module_not_available
from datadiff import tools as dd
+from ming.orm import ThreadLocalORMSession
from allura import model as M
from allura.lib import helpers as h
from allura.lib.search import inject_user
+from allura.lib.security import has_access
+from allura.lib.security import Credentials
from allura.tests import decorators as td
from alluratest.controller import setup_basic_test
@@ -103,6 +106,37 @@ def test_make_roles():
assert h.make_roles([pr._id]).next() == pr
@td.with_wiki
+def test_make_app_admin_only():
+ h.set_context('test', 'wiki', neighborhood='Projects')
+ anon = M.User.anonymous()
+ dev = M.User.query.get(username='test-user')
+ admin = M.User.query.get(username='test-admin')
+ c.project.add_user(dev, ['Developer'])
+ ThreadLocalORMSession.flush_all()
+ Credentials.get().clear()
+ assert has_access(c.app, 'read', user=anon)()
+ assert has_access(c.app, 'read', user=dev)()
+ assert has_access(c.app, 'read', user=admin)()
+ assert not has_access(c.app, 'create', user=anon)()
+ assert has_access(c.app, 'create', user=dev)()
+ assert has_access(c.app, 'create', user=admin)()
+ assert c.app.is_visible_to(anon)
+ assert c.app.is_visible_to(dev)
+ assert c.app.is_visible_to(admin)
+ h.make_app_admin_only(c.app)
+ ThreadLocalORMSession.flush_all()
+ Credentials.get().clear()
+ assert not has_access(c.app, 'read', user=anon)()
+ assert not has_access(c.app, 'read', user=dev)()
+ assert has_access(c.app, 'read', user=admin)()
+ assert not has_access(c.app, 'create', user=anon)()
+ assert not has_access(c.app, 'create', user=dev)()
+ assert has_access(c.app, 'create', user=admin)()
+ assert not c.app.is_visible_to(anon)
+ assert not c.app.is_visible_to(dev)
+ assert c.app.is_visible_to(admin)
+
+@td.with_wiki
def test_context_setters():
h.set_context('test', 'wiki', neighborhood='Projects')
assert c.project is not None
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c6ffac86/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 49397a5..3951c37 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -17,11 +17,13 @@
import logging
import urllib2
+import traceback
from pkg_resources import iter_entry_points
from tg import expose, validate, flash, redirect, config
from tg.decorators import with_trailing_slash
+from pylons import app_globals as g
from pylons import tmpl_context as c
from formencode import validators as fev, schema
@@ -55,9 +57,19 @@ class ProjectImportForm(schema.Schema):
@task(notifications_disabled=True)
def import_tool(importer_name, project_name=None, mount_point=None, mount_label=None, **kw):
- importer = ToolImporter.by_name(importer_name)
- importer.import_tool(c.project, c.user, project_name=project_name,
- mount_point=mount_point, mount_label=mount_label, **kw)
+ try:
+ importer = ToolImporter.by_name(importer_name)
+ importer.import_tool(c.project, c.user, project_name=project_name,
+ mount_point=mount_point, mount_label=mount_label, **kw)
+ except Exception as e:
+ g.post_event('import_tool_task_failed',
+ error=str(e),
+ traceback=traceback.format_exc(),
+ importer_name=importer_name,
+ project_name=project_name,
+ mount_point=mount_point,
+ mount_label=mount_label,
+ **kw)
class ProjectExtractor(object):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c6ffac86/ForgeImporters/forgeimporters/google/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/tracker.py b/ForgeImporters/forgeimporters/google/tracker.py
index 8b1747f..6fa55d5 100644
--- a/ForgeImporters/forgeimporters/google/tracker.py
+++ b/ForgeImporters/forgeimporters/google/tracker.py
@@ -77,6 +77,9 @@ class GoogleCodeTrackerImporter(ToolImporter):
g.post_event('project_updated')
app.globals.invalidate_bin_counts()
return app
+ except Exception as e:
+ h.make_app_admin_only(app)
+ raise
finally:
M.session.artifact_orm_session._get().skip_mod_date = False
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c6ffac86/ForgeImporters/forgeimporters/tests/google/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/google/test_tracker.py b/ForgeImporters/forgeimporters/tests/google/test_tracker.py
index 4a7c28f..8a97913 100644
--- a/ForgeImporters/forgeimporters/tests/google/test_tracker.py
+++ b/ForgeImporters/forgeimporters/tests/google/test_tracker.py
@@ -79,6 +79,20 @@ class TestTrackerImporter(TestCase):
g.post_event.assert_called_once_with('project_updated')
app.globals.invalidate_bin_counts.assert_called_once_with()
+ @mock.patch.object(tracker, 'ThreadLocalORMSession')
+ @mock.patch.object(tracker, 'M')
+ @mock.patch.object(tracker, 'h')
+ def test_import_tool_failure(self, h, M, ThreadLocalORMSession):
+ h.push_config.side_effect = ValueError
+ project = mock.Mock()
+ user = mock.Mock()
+
+ importer = tracker.GoogleCodeTrackerImporter()
+ self.assertRaises(ValueError, importer.import_tool, project, user, project_name='project_name',
+ mount_point='mount_point', mount_label='mount_label')
+
+ h.make_app_admin_only.assert_called_once_with(project.install_app.return_value)
+
def test_custom_fields(self):
importer = tracker.GoogleCodeTrackerImporter()
importer.custom_fields = {}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c6ffac86/ForgeImporters/forgeimporters/tests/test_base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/test_base.py b/ForgeImporters/forgeimporters/tests/test_base.py
index 57ed227..8c04947 100644
--- a/ForgeImporters/forgeimporters/tests/test_base.py
+++ b/ForgeImporters/forgeimporters/tests/test_base.py
@@ -38,7 +38,8 @@ class TestProjectExtractor(TestCase):
@mock.patch.object(base.ToolImporter, 'by_name')
@mock.patch.object(base, 'c')
-def test_import_tool(c, by_name):
+@mock.patch.object(base, 'g')
+def test_import_tool(g, c, by_name):
c.project = mock.Mock(name='project')
c.user = mock.Mock(name='user')
base.import_tool('importer_name', project_name='project_name',
@@ -47,6 +48,23 @@ def test_import_tool(c, by_name):
by_name.return_value.import_tool.assert_called_once_with(c.project,
c.user, project_name='project_name', mount_point='mount_point',
mount_label='mount_label')
+ assert not g.post_event.called
+
+@mock.patch.object(base.ToolImporter, 'by_name')
+@mock.patch.object(base, 'g')
+def test_import_tool_failed(g, by_name):
+ by_name.side_effect = RuntimeError('my error')
+ base.import_tool('importer_name', project_name='project_name',
+ mount_point='mount_point', mount_label='mount_label', other='other')
+ g.post_event.assert_called_once_with(
+ 'import_tool_task_failed',
+ error=by_name.side_effect,
+ importer_name='importer_name',
+ project_name='project_name',
+ mount_point='mount_point',
+ mount_label='mount_label',
+ other='other',
+ )
def ep(name, source=None, importer=None, **kw):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c6ffac86/ForgeImporters/forgeimporters/trac/tests/test_tickets.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tests/test_tickets.py b/ForgeImporters/forgeimporters/trac/tests/test_tickets.py
index 2a539df..7373f3c 100644
--- a/ForgeImporters/forgeimporters/trac/tests/test_tickets.py
+++ b/ForgeImporters/forgeimporters/trac/tests/test_tickets.py
@@ -46,12 +46,13 @@ class TestTracTicketImporter(TestCase):
project = Mock(name='Project', shortname='myproject')
project.install_app.return_value = app
user = Mock(name='User', _id='id')
- res = importer.import_tool(project, user,
- mount_point='bugs',
- mount_label='Bugs',
- trac_url='http://example.com/trac/url',
- user_map=json.dumps(user_map),
- )
+ with patch.dict('forgeimporters.trac.tickets.config', {'base_url': 'foo'}):
+ res = importer.import_tool(project, user,
+ mount_point='bugs',
+ mount_label='Bugs',
+ trac_url='http://example.com/trac/url',
+ user_map=json.dumps(user_map),
+ )
self.assertEqual(res, app)
project.install_app.assert_called_once_with(
'Tickets', mount_point='bugs', mount_label='Bugs')
@@ -68,6 +69,26 @@ class TestTracTicketImporter(TestCase):
validate=False)
g.post_event.assert_called_once_with('project_updated')
+ @patch('forgeimporters.trac.tickets.session')
+ @patch('forgeimporters.trac.tickets.h')
+ @patch('forgeimporters.trac.tickets.TracExport')
+ def test_import_tool_failure(self, TracExport, h, session):
+ importer = TracTicketImporter()
+ app = Mock(name='ForgeTrackerApp')
+ project = Mock(name='Project', shortname='myproject')
+ project.install_app.return_value = app
+ user = Mock(name='User', _id='id')
+ TracExport.side_effect = ValueError
+
+ self.assertRaises(ValueError, importer.import_tool, project, user,
+ mount_point='bugs',
+ mount_label='Bugs',
+ trac_url='http://example.com/trac/url',
+ user_map=None,
+ )
+
+ h.make_app_admin_only.assert_called_once_with(app)
+
class TestTracTicketImportController(TestController, TestCase):
def setUp(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c6ffac86/ForgeImporters/forgeimporters/trac/tickets.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tickets.py b/ForgeImporters/forgeimporters/trac/tickets.py
index dfbb2a2..0c6e2b7 100644
--- a/ForgeImporters/forgeimporters/trac/tickets.py
+++ b/ForgeImporters/forgeimporters/trac/tickets.py
@@ -42,6 +42,7 @@ from allura.controllers import BaseController
from allura.lib.decorators import require_post
from allura.lib.import_api import AlluraImportApiClient
from allura.lib.validators import UserMapJsonFile
+from allura.lib import helpers as h
from allura.model import ApiTicket
from allura.scripts.trac_export import (
TracExport,
@@ -100,16 +101,20 @@ class TracTicketImporter(ToolImporter):
)
session(app.config).flush(app.config)
session(app.globals).flush(app.globals)
- export = [ticket for ticket in TracExport(trac_url)]
- export_string = json.dumps(export, cls=DateJSONEncoder)
- api_ticket = ApiTicket(user_id=user._id,
- capabilities={"import": ["Projects", project.shortname]},
- expires=datetime.utcnow() + timedelta(minutes=60))
- session(api_ticket).flush(api_ticket)
- cli = AlluraImportApiClient(config['base_url'], api_ticket.api_key,
- api_ticket.secret_key, verbose=True)
- import_tracker(cli, project.shortname, mount_point,
- {'user_map': json.loads(user_map) if user_map else {}},
- export_string, validate=False)
- g.post_event('project_updated')
- return app
+ try:
+ export = [ticket for ticket in TracExport(trac_url)]
+ export_string = json.dumps(export, cls=DateJSONEncoder)
+ api_ticket = ApiTicket(user_id=user._id,
+ capabilities={"import": ["Projects", project.shortname]},
+ expires=datetime.utcnow() + timedelta(minutes=60))
+ session(api_ticket).flush(api_ticket)
+ cli = AlluraImportApiClient(config['base_url'], api_ticket.api_key,
+ api_ticket.secret_key, verbose=True)
+ import_tracker(cli, project.shortname, mount_point,
+ {'user_map': json.loads(user_map) if user_map else {}},
+ export_string, validate=False)
+ g.post_event('project_updated')
+ return app
+ except Exception as e:
+ h.make_app_admin_only(app)
+ raise
[17/50] git commit: [#3153] ticket:389 added saved search bins to
tracker bulk_export
Posted by jo...@apache.org.
[#3153] ticket:389 added saved search bins to tracker bulk_export
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/2a60f9a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/2a60f9a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/2a60f9a6
Branch: refs/heads/cj/6530
Commit: 2a60f9a6bf868e940ba8da4ff76a231a1bc320cc
Parents: 59d60f6
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Jul 23 20:46:36 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:42 2013 +0000
----------------------------------------------------------------------
ForgeTracker/forgetracker/model/ticket.py | 8 ++++++++
ForgeTracker/forgetracker/tests/test_app.py | 3 +++
ForgeTracker/forgetracker/tracker_main.py | 3 +++
3 files changed, 14 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2a60f9a6/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 80ce102..0536f71 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -512,6 +512,14 @@ class Bin(Artifact, ActivityObject):
terms_s=self.terms)
return result
+ def __json__(self):
+ return dict(super(Bin,self).__json__(),
+ _id=self._id,
+ summary=self.summary,
+ terms=self.terms,
+ sort=self.sort,
+ )
+
class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
class __mongometa__:
name = 'ticket'
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2a60f9a6/ForgeTracker/forgetracker/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
index a718885..c84fa8d 100644
--- a/ForgeTracker/forgetracker/tests/test_app.py
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -63,3 +63,6 @@ class TestBulkExport(TrackerTestController):
milestones = sorted(tracker['milestones'], key=operator.itemgetter('name'))
assert_equal(milestones[0]['name'], '1.0')
assert_equal(milestones[1]['name'], '2.0')
+
+ saved_bins_summaries = [bin['summary'] for bin in tracker['saved_bins']]
+ assert_true('Closed Tickets' in saved_bins_summaries)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2a60f9a6/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 1880cd8..a0740a9 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -423,6 +423,9 @@ class ForgeTrackerApp(Application):
f.write(', "milestones":')
milestones = self.milestones
json.dump(milestones, f, cls=jsonify.GenericJSON)
+ f.write(', "saved_bins":')
+ bins = self.bins
+ json.dump(bins, f, cls=jsonify.GenericJSON)
f.write('}')
@property
[23/50] git commit: [#3154] ticket:395 updated bulk_export test
Posted by jo...@apache.org.
[#3154] ticket:395 updated bulk_export test
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/c71f754d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c71f754d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c71f754d
Branch: refs/heads/cj/6530
Commit: c71f754dae279d14c47509ac54986518274fd9ed
Parents: 154814e
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Thu Jul 25 17:09:08 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:43 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/test_tasks.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c71f754d/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 06d4ede..cd10683 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -366,21 +366,23 @@ class TestExportTasks(unittest.TestCase):
mock.call('Tool bugs is not exportable. Skipping.'),
mock.call('Tool blog is not exportable. Skipping.')])
+ @mock.patch('allura.model.project.Project.__json__')
@mock.patch('allura.tasks.export_tasks.shutil')
@mock.patch('allura.tasks.export_tasks.zipdir')
@mock.patch('forgewiki.wiki_main.ForgeWikiApp.bulk_export')
@mock.patch('allura.tasks.export_tasks.log')
@td.with_wiki
- def test_bulk_export(self, log, wiki_bulk_export, zipdir, shutil):
+ def test_bulk_export(self, log, wiki_bulk_export, zipdir, shutil, project_json):
M.MonQTask.query.remove()
export_tasks.bulk_export('test', [u'wiki'], 'test-admin')
assert_equal(log.info.call_count, 1)
assert_equal(log.info.call_args_list, [
mock.call('Exporting wiki...')])
wiki_bulk_export.assert_called_once()
+ project_json.assert_called_once()
temp = '/tmp/bulk_export/p/test/test'
zipfn = '/tmp/bulk_export/p/test/test.zip'
- zipdir.assert_caled_once_with(temp, temp + '/test.zip')
+ zipdir.assert_caled_with(temp, temp + '/test.zip')
shutil.move.assert_called_once_with(temp + '/test.zip', zipfn)
shutil.rmtree.assert_called_once_with(temp)
# check notification
[47/50] git commit: [#3154] remove unused Artifact.tool_version and
make tracker models less dependent on `c`
Posted by jo...@apache.org.
[#3154] remove unused Artifact.tool_version and make tracker models less dependent on `c`
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/031f9ae7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/031f9ae7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/031f9ae7
Branch: refs/heads/cj/6530
Commit: 031f9ae7a8bb9ca34564645fb096e01a3a630a8a
Parents: 07d4de9
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Aug 21 15:21:02 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:49:29 2013 +0000
----------------------------------------------------------------------
Allura/allura/controllers/project.py | 7 +--
Allura/allura/model/artifact.py | 6 +--
Allura/allura/tests/test_globals.py | 3 +-
ForgeBlog/forgeblog/command/rssfeeds.py | 1 -
ForgeTracker/forgetracker/model/ticket.py | 54 ++++++++++----------
ForgeTracker/forgetracker/tests/test_app.py | 6 ++-
.../tests/unit/test_globals_model.py | 22 ++++----
scripts/project-import.py | 2 +-
8 files changed, 50 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/031f9ae7/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index d2b8510..5f293a6 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -778,9 +778,8 @@ class NeighborhoodAwardsController(object):
def create(self, icon=None, short=None, full=None):
require_access(self.neighborhood, 'admin')
app_config_id = ObjectId()
- tool_version = {'neighborhood': '0'}
if short:
- award = M.Award(app_config_id=app_config_id, tool_version=tool_version)
+ award = M.Award(app_config_id=app_config_id)
award.short = short
award.full = full
award.created_by_neighborhood_id = self.neighborhood._id
@@ -802,9 +801,7 @@ class NeighborhoodAwardsController(object):
deleted=False)).first()
if grant_q and recipient_q:
app_config_id = ObjectId()
- tool_version = {'neighborhood': '0'}
- award = M.AwardGrant(app_config_id=app_config_id,
- tool_version=tool_version)
+ award = M.AwardGrant(app_config_id=app_config_id)
award.award_id = grant_q._id
award.granted_to_project_id = recipient_q._id
award.granted_by_neighborhood_id = self.neighborhood._id
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/031f9ae7/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index b41b103..294c3d0 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -54,7 +54,6 @@ class Artifact(MappedClass):
- Has a discussion thread that can have files attached to it
:var mod_date: last-modified :class:`datetime`
- :var tool_version: defaults to the parent Application's version
:var acl: dict of permission name => [roles]
:var labels: list of plain old strings
@@ -77,9 +76,7 @@ class Artifact(MappedClass):
mod_date = FieldProperty(datetime, if_missing=datetime.utcnow)
app_config_id = ForeignIdProperty('AppConfig', if_missing=lambda:c.app.config._id)
plugin_verson = FieldProperty(S.Deprecated)
- tool_version = FieldProperty(
- { str: str },
- if_missing=lambda:{c.app.config.tool_name:c.app.__version__})
+ tool_version = FieldProperty(S.Deprecated)
acl = FieldProperty(ACL)
tags = FieldProperty(S.Deprecated)
labels = FieldProperty([str])
@@ -368,6 +365,7 @@ class Artifact(MappedClass):
if t is None:
idx = self.index()
t = Thread.new(
+ app_config_id=self.app_config_id,
discussion_id=self.app_config.discussion_id,
ref_id=idx['id'],
subject='%s discussion' % h.get_first(idx, 'title'))
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/031f9ae7/Allura/allura/tests/test_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 526af04..437021b 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -504,8 +504,7 @@ def test_hideawards_macro():
p_nbhd = M.Neighborhood.query.get(name='Projects')
app_config_id = ObjectId()
- tool_version = {'neighborhood': '0'}
- award = M.Award(app_config_id=app_config_id, tool_version=tool_version)
+ award = M.Award(app_config_id=app_config_id)
award.short = u'Award short'
award.full = u'Award full'
award.created_by_neighborhood_id = p_nbhd._id
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/031f9ae7/ForgeBlog/forgeblog/command/rssfeeds.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/command/rssfeeds.py b/ForgeBlog/forgeblog/command/rssfeeds.py
index f4b5c75..0e70ea9 100644
--- a/ForgeBlog/forgeblog/command/rssfeeds.py
+++ b/ForgeBlog/forgeblog/command/rssfeeds.py
@@ -135,7 +135,6 @@ class RssFeedsCommand(base.BlogCommand):
if b_count == 0:
post = BM.BlogPost(title=title, text=content, timestamp=updated,
app_config_id=appid,
- tool_version={'blog': version.__version__},
state='published')
post.neighborhood_id=c.project.neighborhood_id
post.make_slug()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/031f9ae7/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 0536f71..d16039e 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -73,7 +73,8 @@ class Globals(MappedClass):
type_s = 'Globals'
_id = FieldProperty(schema.ObjectId)
- app_config_id = ForeignIdProperty('AppConfig', if_missing=lambda:c.app.config._id)
+ app_config_id = ForeignIdProperty(AppConfig, if_missing=lambda:c.app.config._id)
+ app_config = RelationProperty(AppConfig, via='app_config_id')
last_ticket_num = FieldProperty(int)
status_names = FieldProperty(str)
open_status_names = FieldProperty(str)
@@ -97,13 +98,12 @@ class Globals(MappedClass):
'labels': False,
})
- @classmethod
- def next_ticket_num(cls):
- gbl = cls.query.find_and_modify(
- query=dict(app_config_id=c.app.config._id),
+ def next_ticket_num(self):
+ gbl = Globals.query.find_and_modify(
+ query=dict(app_config_id=self.app_config_id),
update={'$inc': { 'last_ticket_num': 1}},
new=True)
- session(cls).expunge(gbl)
+ session(gbl).expunge(gbl)
return gbl.last_ticket_num
@property
@@ -189,11 +189,11 @@ class Globals(MappedClass):
return d
mongo_query = {'custom_fields.%s' % fld_name: m_name}
r = Ticket.query.find(dict(
- mongo_query, app_config_id=c.app.config._id, deleted=False))
+ mongo_query, app_config_id=self.app_config_id, deleted=False))
tickets = [t for t in r if security.has_access(t, 'read')]
d['hits'] = len(tickets)
d['closed'] = sum(1 for t in tickets
- if t.status in c.app.globals.set_of_closed_status_names)
+ if t.status in self.set_of_closed_status_names)
return d
def invalidate_bin_counts(self):
@@ -229,13 +229,13 @@ class Globals(MappedClass):
def has_deleted_tickets(self):
return Ticket.query.find(dict(
- app_config_id=c.app.config._id, deleted=True)).count() > 0
+ app_config_id=self.app_config_id, deleted=True)).count() > 0
def move_tickets(self, ticket_ids, destination_tracker_id):
tracker = AppConfig.query.get(_id=destination_tracker_id)
tickets = Ticket.query.find(dict(
_id={'$in': [ObjectId(id) for id in ticket_ids]},
- app_config_id=c.app.config._id)).sort('ticket_num').all()
+ app_config_id=self.app_config_id)).sort('ticket_num').all()
filtered = self.filtered_by_subscription({t._id: t for t in tickets})
original_ticket_nums = {t._id: t.ticket_num for t in tickets}
users = User.query.find({'_id': {'$in': filtered.keys()}}).all()
@@ -247,13 +247,13 @@ class Globals(MappedClass):
fromaddr = str(c.user.email_address_header()),
reply_to = str(c.user.email_address_header()),
subject = '[%s:%s] Mass ticket moving by %s' % (c.project.shortname,
- c.app.config.options.mount_point,
+ self.app_config.options.mount_point,
c.user.display_name))
tmpl = g.jinja2_env.get_template('forgetracker:data/mass_move_report.html')
tmpl_context = {
'original_tracker': '%s:%s' % (c.project.shortname,
- c.app.config.options.mount_point),
+ self.app_config.options.mount_point),
'destination_tracker': '%s:%s' % (tracker.project.shortname,
tracker.options.mount_point),
'tickets': [],
@@ -270,16 +270,16 @@ class Globals(MappedClass):
destinations = [str(user._id)]))
mail_tasks.sendmail.post(**mail)
- if c.app.config.options.get('TicketMonitoringType') in (
+ if self.app_config.options.get('TicketMonitoringType') in (
'AllTicketChanges', 'AllPublicTicketChanges'):
- monitoring_email = c.app.config.options.get('TicketMonitoringEmail')
+ monitoring_email = self.app_config.options.get('TicketMonitoringEmail')
tmpl_context['tickets'] = [{
'original_num': original_ticket_nums[_id],
'destination_num': moved_tickets[_id].ticket_num,
'summary': moved_tickets[_id].summary
} for _id, t in moved_tickets.iteritems()
if (not t.private or
- c.app.config.options.get('TicketMonitoringType') ==
+ self.app_config.options.get('TicketMonitoringType') ==
'AllTicketChanges')]
if len(tmpl_context['tickets']) > 0:
mail.update(dict(
@@ -288,7 +288,7 @@ class Globals(MappedClass):
destinations = [monitoring_email]))
mail_tasks.sendmail.post(**mail)
- moved_from = '%s/%s' % (c.project.shortname, c.app.config.options.mount_point)
+ moved_from = '%s/%s' % (c.project.shortname, self.app_config.options.mount_point)
moved_to = '%s/%s' % (tracker.project.shortname, tracker.options.mount_point)
text = 'Tickets moved from %s to %s' % (moved_from, moved_to)
Notification.post_user(c.user, None, 'flash', text=text)
@@ -297,7 +297,7 @@ class Globals(MappedClass):
from forgetracker.tracker_main import get_change_text, get_label
tickets = Ticket.query.find(dict(
_id={'$in':[ObjectId(id) for id in aslist(post_data['__ticket_ids'])]},
- app_config_id=c.app.config._id)).all()
+ app_config_id=self.app_config_id)).all()
fields = set(['status'])
values = {}
@@ -314,7 +314,7 @@ class Globals(MappedClass):
custom_values = {}
custom_fields = {}
- for cf in c.app.globals.custom_fields or []:
+ for cf in self.custom_fields or []:
v = post_data.get(cf.name)
if v:
custom_values[cf.name] = v
@@ -369,7 +369,7 @@ class Globals(MappedClass):
fromaddr = str(c.user._id),
reply_to = str(c.user._id),
subject = '[%s:%s] Mass edit changes by %s' % (c.project.shortname,
- c.app.config.options.mount_point,
+ self.app_config.options.mount_point,
c.user.display_name),
)
tmpl = g.jinja2_env.get_template('forgetracker:data/mass_report.html')
@@ -394,13 +394,13 @@ class Globals(MappedClass):
destinations = [str(user._id)]))
mail_tasks.sendmail.post(**mail)
- if c.app.config.options.get('TicketMonitoringType') in (
+ if self.app_config.options.get('TicketMonitoringType') in (
'AllTicketChanges', 'AllPublicTicketChanges'):
- monitoring_email = c.app.config.options.get('TicketMonitoringEmail')
+ monitoring_email = self.app_config.options.get('TicketMonitoringEmail')
visible_changes = []
for t_id, t in changed_tickets.items():
if (not t.private or
- c.app.config.options.get('TicketMonitoringType') ==
+ self.app_config.options.get('TicketMonitoringType') ==
'AllTicketChanges'):
visible_changes.append(
(changed_tickets[t_id], jinja2.Markup(changes[t_id])))
@@ -412,16 +412,16 @@ class Globals(MappedClass):
destinations = [monitoring_email]))
mail_tasks.sendmail.post(**mail)
- c.app.globals.invalidate_bin_counts()
+ self.invalidate_bin_counts()
ThreadLocalORMSession.flush_all()
- app = '%s/%s' % (c.project.shortname, c.app.config.options.mount_point)
+ app = '%s/%s' % (c.project.shortname, self.app_config.options.mount_point)
count = len(tickets)
text = 'Updated {} ticket{} in {}'.format(count, 's' if count != 1 else '', app)
Notification.post_user(c.user, None, 'flash', text=text)
def filtered_by_subscription(self, tickets, project_id=None, app_config_id=None):
p_id = project_id if project_id else c.project._id
- ac_id = app_config_id if app_config_id else c.app.config._id
+ ac_id = app_config_id if app_config_id else self.app_config_id
ticket_ids = tickets.keys()
tickets_index_id = {ticket.index_id(): t_id for t_id, ticket in tickets.iteritems()}
subscriptions = Mailbox.query.find({
@@ -678,11 +678,11 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
@property
def monitoring_email(self):
- return c.app.config.options.get('TicketMonitoringEmail')
+ return self.app_config.options.get('TicketMonitoringEmail')
@property
def notify_post(self):
- monitoring_type = c.app.config.options.get('TicketMonitoringType')
+ monitoring_type = self.app_config.options.get('TicketMonitoringType')
return monitoring_type == 'AllTicketChanges' or (
monitoring_type == 'AllPublicTicketChanges' and
not self.private)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/031f9ae7/ForgeTracker/forgetracker/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
index b92a72f..e6e74b8 100644
--- a/ForgeTracker/forgetracker/tests/test_app.py
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -15,12 +15,12 @@
# specific language governing permissions and limitations
# under the License.
-import datetime
import tempfile
import json
import operator
from nose.tools import assert_equal, assert_true
+from pylons import tmpl_context as c
from allura import model as M
from allura.tests import decorators as td
@@ -40,6 +40,10 @@ class TestBulkExport(TrackerTestController):
ticket.discussion_thread.add_post(text='silly comment')
def test_bulk_export(self):
+ # Clear out some context vars, to properly simulate how this is run from the export task
+ # Besides, core functionality shouldn't need the c context vars
+ c.app = c.project = None
+
f = tempfile.TemporaryFile()
self.tracker.bulk_export(f)
f.seek(0)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/031f9ae7/ForgeTracker/forgetracker/tests/unit/test_globals_model.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/unit/test_globals_model.py b/ForgeTracker/forgetracker/tests/unit/test_globals_model.py
index 357caec..c3c0c30 100644
--- a/ForgeTracker/forgetracker/tests/unit/test_globals_model.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_globals_model.py
@@ -15,18 +15,19 @@
# specific language governing permissions and limitations
# under the License.
+from datetime import datetime, timedelta
+
import mock
from nose.tools import assert_equal
-from datetime import datetime, timedelta
+from pylons import tmpl_context as c
+from ming.orm.ormsession import ThreadLocalORMSession
+from bson import ObjectId
import forgetracker
from forgetracker.model import Globals
from forgetracker.tests.unit import TrackerTestWithModel
-from pylons import tmpl_context as c
from allura.lib import helpers as h
-from ming.orm.ormsession import ThreadLocalORMSession
-
class TestGlobalsModel(TrackerTestWithModel):
def setUp(self):
@@ -41,13 +42,15 @@ class TestGlobalsModel(TrackerTestWithModel):
assert c.app.globals != bugs_globals
def test_next_ticket_number_increments(self):
- assert Globals.next_ticket_num() == 1
- assert Globals.next_ticket_num() == 2
+ gl = Globals()
+ assert_equal(gl.next_ticket_num(), 1)
+ assert_equal(gl.next_ticket_num(), 2)
def test_ticket_numbers_are_independent(self):
- assert Globals.next_ticket_num() == 1
- h.set_context('test', 'doc-bugs', neighborhood='Projects')
- assert Globals.next_ticket_num() == 1
+ with h.push_context('test', 'doc-bugs', neighborhood='Projects'):
+ assert_equal(c.app.globals.next_ticket_num(), 1)
+ with h.push_context('test', 'bugs', neighborhood='Projects'):
+ assert_equal(c.app.globals.next_ticket_num(), 1)
@mock.patch('forgetracker.model.ticket.datetime')
def test_bin_count(self, mock_dt):
@@ -133,4 +136,3 @@ def globals_with_custom_fields(custom_fields):
c.app.globals.custom_fields = custom_fields
ThreadLocalORMSession.flush_all()
return c.app.globals
-
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/031f9ae7/scripts/project-import.py
----------------------------------------------------------------------
diff --git a/scripts/project-import.py b/scripts/project-import.py
index 5855da6..f4ba62f 100644
--- a/scripts/project-import.py
+++ b/scripts/project-import.py
@@ -240,7 +240,7 @@ def create_project(p, nbhd, user, options):
for a in p.awards:
M.AwardGrant(app_config_id=bson.ObjectId(),
- tool_version=dict(neighborhood='0'), award_id=a._id,
+ award_id=a._id,
granted_to_project_id=project._id,
granted_by_neighborhood_id=nbhd._id)
project.notifications_disabled = False
[05/50] git commit: [#3154] ticket:388 Add not exported tools to
notification email
Posted by jo...@apache.org.
[#3154] ticket:388 Add not exported tools to notification email
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/cde71c36
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/cde71c36
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/cde71c36
Branch: refs/heads/cj/6530
Commit: cde71c3623e3fe8e2f6403b065bfcaa4caae50fe
Parents: b5f79e6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Jul 5 13:35:34 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:40 2013 +0000
----------------------------------------------------------------------
Allura/allura/tasks/export_tasks.py | 7 ++++++-
Allura/allura/templates/mail/bulk_export.html | 7 +++++++
2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cde71c36/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index d097205..672f51b 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -41,13 +41,16 @@ def bulk_export(project_shortname, tools, username):
if project.bulk_export_status() == 'busy':
log.info('Another export is running for project %s. Skipping.' % project_shortname)
return
+ not_exported_tools = []
for tool in tools or []:
app = project.app_instance(tool)
if not app:
log.info('Can not load app for %s mount point. Skipping.' % tool)
+ not_exported_tools.append(tool)
continue
if not app.exportable:
log.info('Tool %s is not exportable. Skipping.' % tool)
+ not_exported_tools.append(tool)
continue
log.info('Exporting %s...' % tool)
try:
@@ -56,6 +59,7 @@ def bulk_export(project_shortname, tools, username):
app.bulk_export(f)
except:
log.error('Something went wrong during export of %s' % tool, exc_info=True)
+ not_exported_tools.append(tool)
continue
try:
@@ -73,7 +77,8 @@ def bulk_export(project_shortname, tools, username):
tmpl_context = {
'instructions': instructions,
'project': project,
- 'tools': tools,
+ 'tools': list(set(tools) - set(not_exported_tools)),
+ 'not_exported_tools': not_exported_tools,
}
email = {
'fromaddr': unicode(user.email_address_header()),
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cde71c36/Allura/allura/templates/mail/bulk_export.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/mail/bulk_export.html b/Allura/allura/templates/mail/bulk_export.html
index 420848f..95ade78 100644
--- a/Allura/allura/templates/mail/bulk_export.html
+++ b/Allura/allura/templates/mail/bulk_export.html
@@ -24,6 +24,13 @@ Following tools was exported:
- {{ tool }}
{% endfor %}
+{% if not_exported_tools %}
+Following tools was not exported:
+{% for tool in not_exported_tools %}
+- {{ tool }}
+{% endfor %}
+{% endif %}
+
Follow instructions below to get exported data.
{{ instructions }}
[41/50] git commit: [#3154] ticket:411 test fixes for zip_and_cleanup
Posted by jo...@apache.org.
[#3154] ticket:411 test fixes for zip_and_cleanup
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/68ed96ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/68ed96ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/68ed96ee
Branch: refs/heads/cj/6530
Commit: 68ed96eec0d97bc04fb4e539c936fa6fadef4f30
Parents: 9a39fca
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Aug 13 17:25:27 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:45 2013 +0000
----------------------------------------------------------------------
Allura/allura/tasks/export_tasks.py | 9 ++++++---
ForgeDiscussion/forgediscussion/tests/test_app.py | 2 ++
2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/68ed96ee/Allura/allura/tasks/export_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 3e2a9af..b5fcb34 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -72,9 +72,12 @@ def bulk_export(project_shortname, tools, username, neighborhood):
except:
log.error('Something went wrong during export of project metadata', exc_info=True)
- # If that fails, we need to let it fail
- # there won't be a valid zip file for the user to get.
- zip_and_cleanup(project)
+ if tools and len(not_exported_tools) < len(tools):
+ # If that fails, we need to let it fail
+ # there won't be a valid zip file for the user to get.
+ zip_and_cleanup(project)
+ else:
+ log.error('Nothing to export')
user = M.User.by_username(username)
if not user:
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/68ed96ee/ForgeDiscussion/forgediscussion/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/tests/test_app.py b/ForgeDiscussion/forgediscussion/tests/test_app.py
index bc9dcb1..07b65f4 100644
--- a/ForgeDiscussion/forgediscussion/tests/test_app.py
+++ b/ForgeDiscussion/forgediscussion/tests/test_app.py
@@ -41,6 +41,8 @@ class TestBulkExport(TestDiscussionApiBase):
assert_equal(forums[0]['shortname'], u'general')
assert_equal(forums[0]['description'], u'Forum about anything you want to talk about.')
assert_equal(forums[0]['name'], u'General Discussion')
+ forums[0]['threads'] = sorted(forums[0]['threads'],
+ key=lambda x: x['posts'][0]['subject'])
assert_equal(forums[0]['threads'][0]['posts'][0]['text'], u'Hi boys and girls')
assert_equal(forums[0]['threads'][0]['posts'][0]['subject'], u'Hi guys')
assert_equal(forums[0]['threads'][1]['posts'][0]['text'], u'1st post')
[08/50] git commit: [#3153] ticket:389 added config to tracker
bulk_export
Posted by jo...@apache.org.
[#3153] ticket:389 added config to tracker bulk_export
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d5e1ff1b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d5e1ff1b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d5e1ff1b
Branch: refs/heads/cj/6530
Commit: d5e1ff1bdf443bd159c1796abe2d9767f25709f3
Parents: 208d57f
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Jul 23 18:30:31 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:41 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/project.py | 14 ++++++++++++++
ForgeTracker/forgetracker/tests/test_app.py | 11 +++++++++--
ForgeTracker/forgetracker/tracker_main.py | 4 +++-
3 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d5e1ff1b/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index fb14fc7..b6d6a1f 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -902,3 +902,17 @@ class AppConfig(MappedClass):
def breadcrumbs(self):
return self.project.breadcrumbs() + [
(self.options.mount_point, self.url()) ]
+
+ def __json__(self):
+ return dict(
+ _id=self._id,
+ project_id=self.project_id,
+ discussion_id=self.discussion_id,
+ tool_name=self.tool_name,
+ version=self.version,
+ options=self.options,
+ # project=self.project,
+ # discussion=self.discussion
+ tool_data=self.tool_data,
+ acl=self.acl,
+ )
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d5e1ff1b/ForgeTracker/forgetracker/tests/test_app.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/test_app.py b/ForgeTracker/forgetracker/tests/test_app.py
index e99948b..7437e4d 100644
--- a/ForgeTracker/forgetracker/tests/test_app.py
+++ b/ForgeTracker/forgetracker/tests/test_app.py
@@ -20,7 +20,7 @@ import tempfile
import json
import operator
-from nose.tools import assert_equal
+from nose.tools import assert_equal, assert_true
from allura import model as M
from allura.tests import decorators as td
@@ -44,6 +44,7 @@ class TestBulkExport(TrackerTestController):
self.tracker.bulk_export(f)
f.seek(0)
tracker = json.loads(f.read())
+
tickets = sorted(tracker['tickets'], key=operator.itemgetter('summary'))
assert_equal(len(tickets), 2)
ticket_foo = tickets[1]
@@ -51,4 +52,10 @@ class TestBulkExport(TrackerTestController):
assert_equal(ticket_foo['custom_fields']['_milestone'], '1.0')
posts_foo = ticket_foo['discussion_thread']['posts']
assert_equal(len(posts_foo), 1)
- assert_equal(posts_foo[0]['text'], 'silly comment')
+ assert_equal(posts_foo[0]['text'], 'silly comment')
+
+ tracker_config = tracker['tracker_config']
+ assert_equal(tracker_config['project_id'], unicode(self.project._id))
+ assert_true('options' in tracker_config.keys())
+ assert_true('acl' in tracker_config.keys())
+ assert_equal(tracker_config['options']['mount_point'], 'bugs')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d5e1ff1b/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 4a622c5..5c574e3 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -418,7 +418,9 @@ class ForgeTrackerApp(Application):
json.dump(ticket, f, cls=jsonify.GenericJSON)
if i < (count - 1):
f.write(',')
- f.write(']}')
+ f.write('], "tracker_config":')
+ json.dump(self.config, f, cls=jsonify.GenericJSON)
+ f.write('}')
@property
def bins(self):
[14/50] git commit: [#3154] ticket:395 created project __json__
Posted by jo...@apache.org.
[#3154] ticket:395 created project __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/ef74610f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/ef74610f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/ef74610f
Branch: refs/heads/cj/6530
Commit: ef74610fdc6828f721506073ee871e5a9ffadabd
Parents: d79c80b
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Wed Jul 24 16:44:02 2013 +0300
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:04:42 2013 +0000
----------------------------------------------------------------------
Allura/allura/controllers/rest.py | 6 +-----
Allura/allura/model/project.py | 7 +++++++
2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ef74610f/Allura/allura/controllers/rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index 6a41be3..d1b6cb1 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -281,8 +281,4 @@ class ProjectRestController(object):
@expose('json:')
def index(self, **kw):
- return dict(
- name=c.project.shortname,
- tools=[dict(name=t.tool_name, mount_point=t.options.mount_point, label=t.options.mount_label)
- for t in c.project.app_configs if h.has_access(t, 'read')]
- )
+ return c.project.__json__()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ef74610f/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 02fddac..1525eec 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -837,6 +837,13 @@ class Project(MappedClass, ActivityNode, ActivityObject):
elif os.path.exists(tmpdir):
return 'busy'
+ def __json__(self):
+ return dict(
+ name=self.shortname,
+ tools=[dict(name=t.tool_name, mount_point=t.options.mount_point, label=t.options.mount_label)
+ for t in self.app_configs if h.has_access(t, 'read')]
+ )
+
class AppConfig(MappedClass):
"""
[44/50] git commit: [#3154] don't hide task errors when run in tests
Posted by jo...@apache.org.
[#3154] don't hide task errors when run in tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/07d4de95
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/07d4de95
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/07d4de95
Branch: refs/heads/cj/6530
Commit: 07d4de958db20c65cae6c4bfedba93575bfff8cc
Parents: a779ed7
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Aug 21 15:19:43 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 20:49:28 2013 +0000
----------------------------------------------------------------------
Allura/allura/model/monq_model.py | 17 +++++++++++------
Allura/allura/tests/test_tasks.py | 3 ++-
Allura/test.ini | 3 +++
3 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/07d4de95/Allura/allura/model/monq_model.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/monq_model.py b/Allura/allura/model/monq_model.py
index 3163ea5..faac14b 100644
--- a/Allura/allura/model/monq_model.py
+++ b/Allura/allura/model/monq_model.py
@@ -23,6 +23,8 @@ from datetime import datetime, timedelta
import pymongo
from pylons import tmpl_context as c, app_globals as g
+from tg import config
+from paste.deploy.converters import asbool
import ming
from ming.utils import LazyProperty
@@ -257,13 +259,16 @@ class MonQTask(MappedClass):
self.state = 'complete'
return self.result
except Exception, exc:
- log.exception('Error "%s" on job %s', exc, self)
- self.state = 'error'
- if hasattr(exc, 'format_error'):
- self.result = exc.format_error()
- log.error(self.result)
+ if asbool(config.get('monq.raise_errors')):
+ raise
else:
- self.result = traceback.format_exc()
+ log.exception('Error "%s" on job %s', exc, self)
+ self.state = 'error'
+ if hasattr(exc, 'format_error'):
+ self.result = exc.format_error()
+ log.error(self.result)
+ else:
+ self.result = traceback.format_exc()
finally:
self.time_stop = datetime.utcnow()
session(self).flush(self)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/07d4de95/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 9f307ee..26bcb36 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -81,7 +81,8 @@ class TestEventTasks(unittest.TestCase):
setup_basic_test()
setup_global_objects()
t = raise_exc.post()
- with LogCapture(level=logging.ERROR) as l:
+ with LogCapture(level=logging.ERROR) as l, \
+ mock.patch.dict(tg.config, {'monq.raise_errors': False}): # match normal non-test behavior
t()
# l.check() would be nice, but string is too detailed to check
assert_equal(l.records[0].name, 'allura.model.monq_model')
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/07d4de95/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index 2546149..9892e3c 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -68,6 +68,9 @@ load_test_data = true
cache_test_data = false
site_admin_project = test
+# useful primarily for test suites, where we want to see the error right away
+monq.raise_errors = true
+
# Set the locations of some static resources
# script_name is the path that is handled by the application
# url_base is the prefix that references to the static resources should have