diff --git a/ckan/config/routing.py b/ckan/config/routing.py index c44a86cb9c7..6e798311706 100644 --- a/ckan/config/routing.py +++ b/ckan/config/routing.py @@ -231,18 +231,19 @@ def make_map(): # These named routes are used for custom group forms which will use the # names below based on the group.type (dataset_group is the default type) - map.connect('dataset_group_index', '/group', controller='group', action='index') - map.connect('dataset_group_list', '/group/list', controller='group', action='list') - map.connect('dataset_group_new', '/group/new', controller='group', action='new') - map.connect('dataset_group_action', '/group/{action}/{id}', controller='group', + map.connect('group_index', '/group', controller='group', action='index') + map.connect('group_list', '/group/list', controller='group', action='list') + map.connect('group_new', '/group/new', controller='group', action='new') + map.connect('group_action', '/group/{action}/{id}', controller='group', requirements=dict(action='|'.join([ 'edit', 'authz', 'history' ])) ) - map.connect('dataset_group_read', '/group/{id}', controller='group', action='read') - + map.connect('group_read', '/group/{id}', controller='group', action='read') + + register_package_behaviour(map) register_group_behaviour(map) diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py index 4b434bcc379..0240e0f45bb 100644 --- a/ckan/controllers/group.py +++ b/ckan/controllers/group.py @@ -32,7 +32,7 @@ def register_pluggable_behaviour(map): exception will be raised. """ global _default_controller_behaviour - + # Create the mappings and register the fallback behaviour if one is found. for plugin in PluginImplementations(IGroupForm): if plugin.is_fallback(): @@ -45,6 +45,12 @@ def register_pluggable_behaviour(map): # Create the routes based on group_type here, this will allow us to have top level # objects that are actually Groups, but first we need to make sure we are not # clobbering an existing domain + from routes import url_for + + u = url_for('/%s/new' % (group_type,) ) + if u != '%s_new' % (group_type,): + raise Exception, "Plugin %r would overwrite the default group urls" % plugin + map.connect('%s_new' % (group_type,), '/%s/new' % (group_type,), controller='group', action='new') map.connect('%s_read' % (group_type,), @@ -325,7 +331,7 @@ def _save_new(self, context, group_type=None): try: data_dict = clean_dict(unflatten( tuplize_dict(parse_params(request.params)))) - data_dict['type'] = group_type or 'dataset_group' + data_dict['type'] = group_type or 'group' context['message'] = data_dict.get('log_message', '') group = get_action('group_create')(context, data_dict) diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py index 8aaefd76ef9..045d4ddecd8 100644 --- a/ckan/controllers/package.py +++ b/ckan/controllers/package.py @@ -85,6 +85,10 @@ def register_pluggable_behaviour(map): for package_type in plugin.package_types(): # Create a connection between the newly named type and the package controller # but first we need to make sure we are not clobbering an existing domain + if package_type == 'package': + raise Exception, "The plugin %r would overwrite the default package " \ + "implementation urls" % plugin + map.connect('/%s/new' % (package_type,), controller='package', action='new') map.connect('%s_read' % (package_type,), '/%s/{id}' % (package_type,), controller='package', action='read') map.connect('%s_action' % (package_type,), diff --git a/ckan/migration/versions/047_rename_package_group_member.py b/ckan/migration/versions/047_rename_package_group_member.py index f06afb05645..dd3bca18c27 100644 --- a/ckan/migration/versions/047_rename_package_group_member.py +++ b/ckan/migration/versions/047_rename_package_group_member.py @@ -78,8 +78,8 @@ def upgrade(migrate_engine): update member set table_name = 'package', capacity = 'member'; update member_revision set table_name = 'package', capacity = 'member'; -update "group" set type = 'dataset_group'; -update group_revision set type = 'dataset_group'; +update "group" set type = 'group'; +update group_revision set type = 'group'; ALTER TABLE "member" diff --git a/ckan/model/group.py b/ckan/model/group.py index efb5174ed4a..11b806e935e 100644 --- a/ckan/model/group.py +++ b/ckan/model/group.py @@ -57,7 +57,7 @@ def related_packages(self): class Group(vdm.sqlalchemy.RevisionedObjectMixin, vdm.sqlalchemy.StatefulObjectMixin, DomainObject): - def __init__(self, name=u'', title=u'', description=u'', type=u'dataset_group'): + def __init__(self, name=u'', title=u'', description=u'', type=u'group'): self.name = name self.title = title self.description = description diff --git a/ckan/tests/lib/test_dictization.py b/ckan/tests/lib/test_dictization.py index 1b1001329c4..6d67cf3563c 100644 --- a/ckan/tests/lib/test_dictization.py +++ b/ckan/tests/lib/test_dictization.py @@ -37,12 +37,12 @@ def setup_class(cls): {'key': u'original media', 'state': u'active', 'value': u'"book"'}], 'groups': [{'description': u'These are books that David likes.', 'name': u'david', - 'type': u'dataset_group', + 'type': u'group', 'state': u'active', 'title': u"Dave's books"}, {'description': u'Roger likes these books.', 'name': u'roger', - 'type': u'dataset_group', + 'type': u'group', 'state': u'active', 'title': u"Roger's books"}], 'isopen': True, @@ -868,7 +868,7 @@ def test_16_group_dictized(self): 'version': u'0.7a'}], 'state': u'active', 'title': u'help', - 'type': u'dataset_group'} + 'type': u'group'} expected['packages'] = sorted(expected['packages'], key=lambda x: x['name'])