Skip to content

Commit

Permalink
Merge branch '2375-demo-organizations' of github.com:okfn/ckan into 2…
Browse files Browse the repository at this point in the history
…375-demo-organizations
  • Loading branch information
Sean Hammond committed Sep 13, 2012
2 parents 1ec3ef7 + 253f820 commit e1ef7a5
Show file tree
Hide file tree
Showing 22 changed files with 175 additions and 52 deletions.
23 changes: 23 additions & 0 deletions ckan/public/base/javascript/modules/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ this.ckan.module('autocomplete', function (jQuery, _) {
tags: false,
items: 10,
source: null,
completions: null,
interval: 1000,
dropdownClass: '',
containerClass: '',
Expand Down Expand Up @@ -98,6 +99,9 @@ this.ckan.module('autocomplete', function (jQuery, _) {
var source = parts.join('?') + encodeURIComponent(string) + end;
var client = this.sandbox.client;
var options = {format: client.parseCompletionsForPlugin};
if (this.options.completions) {
options.format = this[this.options.completions];
}

return client.getCompletions(source, options, fn);
},
Expand Down Expand Up @@ -223,6 +227,25 @@ this.ckan.module('autocomplete', function (jQuery, _) {
return formatted;
},

/* Callback for completions for when querying users
*
* Returns results object
*/
parseCompletionsForUsers: function (data) {
var users = [];
jQuery.each(data, function() {
if (typeof this.name != 'undefined') {
users.push({
id: this.name,
text: this.name
});
} else {
users.push(this);
}
});
return { results: users };
},

/* Callback triggered when the select2 plugin needs to make a request.
*
* Returns nothing.
Expand Down
14 changes: 8 additions & 6 deletions ckan/templates/organization/users_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@
</tbody>
</table>

<legend>{{ _('Add user') }}</legend>
<div class="control-group organization-adduser">
<label for="users__{{data.users|length}}__name" class="control-label">{{ _('Username') }}</label>
<div class="controls">
<input id="users__{{data.users|length}}__name" name="users__{{data.users|length}}__name" type="text">
<input id="users__{{data.users|length}}__capacity" name="users__{{data.users|length}}__capacity" value="editor" type="hidden">
<div class="organization-adduser">
<legend>{{ _('Add user') }}</legend>
<div class="control-group">
<label for="users__{{data.users|length}}__name" class="control-label">{{ _('Username') }}</label>
<div class="controls">
<input id="users__{{data.users|length}}__name" name="users__{{data.users|length}}__name" type="text" data-module="autocomplete" data-module-source="/api/2/util/user/autocomplete?q=?" data-module-completions="parseCompletionsForUsers">
<input id="users__{{data.users|length}}__capacity" name="users__{{data.users|length}}__capacity" value="editor" type="hidden">
</div>
</div>
</div>

Expand Down
2 changes: 2 additions & 0 deletions ckan/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
'CkanServerCase',
]


here_dir = os.path.dirname(os.path.abspath(__file__))
conf_dir = os.path.dirname(os.path.dirname(here_dir))

Expand Down Expand Up @@ -404,3 +405,4 @@ class StatusCodes:
STATUS_404_NOT_FOUND = 404
STATUS_409_CONFLICT = 409


3 changes: 3 additions & 0 deletions ckan/tests/functional/test_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class TestActivity(HtmlCheckMethods):
"""
@classmethod
def setup(cls):
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

ckan.tests.CreateTestData.create()
cls.sysadmin_user = ckan.model.User.get('testsysadmin')
cls.app = paste.fixture.TestApp(pylonsapp)
Expand Down
14 changes: 9 additions & 5 deletions ckan/tests/functional/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import ckan.model as model
from ckan.tests import url_for, CreateTestData, WsgiAppCase
from nose.plugins.skip import SkipTest

class TestAdminController(WsgiAppCase):
@classmethod
def setup_class(cls):
raise SkipTest()
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")


# setup test data including testsysadmin user
CreateTestData.create()
Expand Down Expand Up @@ -34,11 +35,12 @@ class TestAdminAuthzController(WsgiAppCase):

@classmethod
def setup_class(cls):
# setup test data including testsysadmin user
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

CreateTestData.create()
model.Session.commit()

raise SkipTest()

@classmethod
def teardown_class(self):
Expand Down Expand Up @@ -160,9 +162,11 @@ def get_roles_by_name(user=None, group=None):

class TestAdminTrashController(WsgiAppCase):
def setup(cls):
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

model.repo.rebuild_db()
CreateTestData.create()
raise SkipTest()

def teardown(self):
model.repo.rebuild_db()
Expand Down
8 changes: 6 additions & 2 deletions ckan/tests/functional/test_authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class AuthzTestBase(object):

@classmethod
def setup_class(self):
raise SkipTest()
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

setup_test_search_index()
self._create_test_data()
model.Session.remove()
Expand Down Expand Up @@ -592,7 +594,9 @@ class TestLockedDownViaRoles(TestController):
'''
@classmethod
def setup_class(self):
raise SkipTest()
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

model.repo.init_db()
q = model.Session.query(model.UserObjectRole) \
.filter(sa.or_(model.UserObjectRole.role==model.Role.EDITOR,
Expand Down
3 changes: 3 additions & 0 deletions ckan/tests/functional/test_edit_authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def check_and_set_checkbox(theform, user, role, should_be, set_to):
class TestEditAuthz(TestController):
@classmethod
def setup_class(self):
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

# for the authorization editing tests we set up test data so:
# three users, sysadmin , administrator, and another
# one group, one package
Expand Down
13 changes: 8 additions & 5 deletions ckan/tests/functional/test_follow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class TestFollow(HtmlCheckMethods):

@classmethod
def setupClass(cls):
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

ckan.tests.CreateTestData.create()
cls.testsysadmin = ckan.model.User.get('testsysadmin')
cls.annafan = ckan.model.User.get('annafan')
Expand Down Expand Up @@ -66,8 +69,8 @@ def test_dataset_read_not_logged_in(self):
assert 'href="/dataset/followers/annakarenina"' in result
assert 'Followers (3)' in result
assert 'id="dataset_follow_button"' not in result
def test_dataset_followers_not_logged_in(self):

def test_dataset_followers_not_logged_in(self):
offset = url_for(controller='package', action='followers',
id='warandpeace')
result = self.app.get(offset)
Expand Down Expand Up @@ -101,7 +104,7 @@ def test_user_read_not_logged_in(self):
assert 'href="/user/followers/annafan"' in result
assert 'Followers (2)' in result
assert 'id="user_follow_button"' not in result

def test_user_followers_not_logged_in(self):
offset = url_for(controller='user', action='followers',
id='joeadmin')
Expand Down Expand Up @@ -137,7 +140,7 @@ def test_own_user_read_logged_in(self):
assert 'href="/user/followers/annafan"' in result
assert 'My Followers (2)' in result
assert 'id="user_follow_button"' not in result

def test_own_user_followers_logged_in(self):
offset = url_for(controller='user', action='followers',
id='joeadmin')
Expand Down Expand Up @@ -205,7 +208,7 @@ def test_dataset_follow_logged_in(self):
extra_environ = {'Authorization': str(self.joeadmin.apikey)}
result = self.app.get(offset, extra_environ=extra_environ)
assert 'Unfollow' in result

def test_user_read_logged_in(self):
offset = url_for(controller='user', action='read',
id='joeadmin')
Expand Down
10 changes: 5 additions & 5 deletions ckan/tests/functional/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TestGroup(FunctionalTestCase):
@classmethod
def setup_class(self):
from nose import SkipTest
raise SkipTest("Use organizations instead of groups")
raise SkipTest("Disable UI tests for 2.0 branch")

model.Session.remove()
CreateTestData.create()
Expand Down Expand Up @@ -234,7 +234,7 @@ class TestGroupWithSearch(FunctionalTestCase):
@classmethod
def setup_class(self):
from nose import SkipTest
raise SkipTest("Use organizations instead of groups")
raise SkipTest("Disable UI tests for 2.0 branch")

setup_test_search_index()
model.Session.remove()
Expand Down Expand Up @@ -280,7 +280,7 @@ class TestEdit(FunctionalTestCase):
@classmethod
def setup_class(self):
from nose import SkipTest
raise SkipTest("Use organizations instead of groups")
raise SkipTest("Disable UI tests for 2.0 branch")

setup_test_search_index()
model.Session.remove()
Expand Down Expand Up @@ -507,7 +507,7 @@ class TestNew(FunctionalTestCase):
@classmethod
def setup_class(self):
from nose import SkipTest
raise SkipTest("Use organizations instead of groups")
raise SkipTest("Disable UI tests for 2.0 branch")

model.Session.remove()
CreateTestData.create()
Expand Down Expand Up @@ -627,7 +627,7 @@ class TestRevisions(FunctionalTestCase):
@classmethod
def setup_class(self):
from nose import SkipTest
raise SkipTest("Use organizations instead of groups")
raise SkipTest("Disable UI tests for 2.0 branch")

model.Session.remove()
CreateTestData.create()
Expand Down
19 changes: 14 additions & 5 deletions ckan/tests/functional/test_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
class TestHomeController(TestController, PylonsTestCase, HtmlCheckMethods):
@classmethod
def setup_class(cls):
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

setup_test_search_index()
PylonsTestCase.setup_class()
model.repo.init_db()
CreateTestData.create()

@classmethod
def teardown_class(self):
model.repo.rebuild_db()
Expand All @@ -36,7 +39,7 @@ def test_packages_link(self):
offset = url_for('home')
res = self.app.get(offset)
res.click('Search', index=0)

def test_template_head_end(self):
offset = url_for('home')
res = self.app.get(offset)
Expand Down Expand Up @@ -98,7 +101,7 @@ def test_template_footer_end(self):
## tag='a', href_attr='href',
## href_extract=None,
## content='Deutsch',
## id=None,
## id=None,
## href_pattern=None,
## html_pattern=None,
## index=None, verbose=False)
Expand Down Expand Up @@ -219,12 +222,15 @@ def test_update_profile_notice(self):
class TestHomeControllerWithoutSearch(TestController, PylonsTestCase, HtmlCheckMethods):
@classmethod
def setup_class(cls):
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

PylonsTestCase.setup_class()

@classmethod
def teardown_class(self):
model.repo.rebuild_db()

def test_404(self):
offset = '/some_nonexistent_url'
res = self.app.get(offset, status=404)
Expand All @@ -238,6 +244,9 @@ def test_about(self):
class TestDatabaseNotInitialised(TestController):
@classmethod
def setup_class(cls):
from nose import SkipTest
raise SkipTest("Disable UI tests for 2.0 branch")

PylonsTestCase.setup_class()
model.repo.clean_db()

Expand Down

0 comments on commit e1ef7a5

Please sign in to comment.