Skip to content

Commit

Permalink
Merge branch 'master' into feature-1669-publisher-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Jan 24, 2012
2 parents eae37ad + bda3142 commit 60b06f3
Show file tree
Hide file tree
Showing 38 changed files with 1,421 additions and 124 deletions.
1 change: 1 addition & 0 deletions ckan/authz.py
Expand Up @@ -47,6 +47,7 @@ def is_authorized(cls, username, action, domain_object):
if isinstance(username, str):
username = username.decode('utf8')
assert isinstance(username, unicode), type(username)

for extension in cls.extensions:
authorized = extension.is_authorized(username,
action,
Expand Down
13 changes: 12 additions & 1 deletion ckan/ckan_nose_plugin.py
Expand Up @@ -47,10 +47,21 @@ def options(self, parser, env):
'--ckan-migration',
action='store_true',
dest='ckan_migration',
help='set this when wanting to test migrations')
help='set this when wanting to test migrations')
parser.add_option(
'--docstrings',
action='store_true',
dest='docstrings',
help='set this to display test docstrings instead of module names')

def configure(self, settings, config):
CkanNose.settings = settings
if settings.is_ckan:
self.enabled = True
self.is_first_test = True

def describeTest(self, test):
if not CkanNose.settings.docstrings:
# display module name instead of docstring
return False

66 changes: 57 additions & 9 deletions ckan/config/routing.py
Expand Up @@ -8,6 +8,9 @@
from pylons import config
from routes import Mapper
from ckan.plugins import PluginImplementations, IRoutes
from ckan.controllers.package import register_pluggable_behaviour as register_package_behaviour
from ckan.controllers.group import register_pluggable_behaviour as register_group_behaviour


routing_plugins = PluginImplementations(IRoutes)

Expand All @@ -23,12 +26,12 @@ def make_map():
map.connect('/error/{action}', controller='error')
map.connect('/error/{action}/{id}', controller='error')

map.connect('*url', controller='home', action='cors_options', conditions=dict(method=['OPTIONS']))

# CUSTOM ROUTES HERE
for plugin in routing_plugins:
map = plugin.before_map(map)

map.connect('*url', controller='home', action='cors_options',
conditions=dict(method=['OPTIONS']))

map.connect('home', '/', controller='home', action='index')
map.connect('/locale', controller='home', action='locale')
map.connect('about', '/about', controller='home', action='about')
Expand Down Expand Up @@ -176,7 +179,7 @@ def make_map():
###########
## /END API
###########

map.redirect("/packages", "/dataset")
map.redirect("/packages/{url:.*}", "/dataset/{url}")
map.redirect("/package", "/dataset")
Expand Down Expand Up @@ -227,17 +230,24 @@ def make_map():
##map.connect('/group/new', controller='group_formalchemy', action='new')
##map.connect('/group/edit/{id}', controller='group_formalchemy', action='edit')

map.connect('/group', controller='group', action='index')
map.connect('/group/list', controller='group', action='list')
map.connect('/group/new', controller='group', action='new')
map.connect('/group/{action}/{id}', controller='group',
# 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('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('/group/{id}', controller='group', action='read')
map.connect('group_read', '/group/{id}', controller='group', action='read')


register_package_behaviour(map)
register_group_behaviour(map)

# authz group
map.redirect("/authorizationgroups", "/authorizationgroup")
map.redirect("/authorizationgroups/{url:.*}", "/authorizationgroup/{url}")
Expand Down Expand Up @@ -278,9 +288,47 @@ def make_map():
map.connect('ckanadmin_index', '/ckan-admin', controller='admin', action='index')
map.connect('ckanadmin', '/ckan-admin/{action}', controller='admin')

# Storage routes
map.connect('storage_api', "/api/storage",
controller='ckan.controllers.storage:StorageAPIController',
action='index')
map.connect('storage_api_set_metadata', '/api/storage/metadata/{label:.*}',
controller='ckan.controllers.storage:StorageAPIController',
action='set_metadata',
conditions={'method': ['PUT','POST']})
map.connect('storage_api_get_metadata', '/api/storage/metadata/{label:.*}',
controller='ckan.controllers.storage:StorageAPIController',
action='get_metadata',
conditions={'method': ['GET']})
map.connect('storage_api_auth_request',
'/api/storage/auth/request/{label:.*}',
controller='ckan.controllers.storage:StorageAPIController',
action='auth_request')
map.connect('storage_api_auth_form',
'/api/storage/auth/form/{label:.*}',
controller='ckan.controllers.storage:StorageAPIController',
action='auth_form')
map.connect('storage_upload', '/storage/upload',
controller='ckan.controllers.storage:StorageController',
action='upload')
map.connect('storage_upload_handle', '/storage/upload_handle',
controller='ckan.controllers.storage:StorageController',
action='upload_handle')
map.connect('storage_upload_success', '/storage/upload/success',
controller='ckan.controllers.storage:StorageController',
action='success')
map.connect('storage_upload_success_empty', '/storage/upload/success_empty',
controller='ckan.controllers.storage:StorageController',
action='success_empty')
map.connect('storage_file', '/storage/f/{label:.*}',
controller='ckan.controllers.storage:StorageController',
action='file')


for plugin in routing_plugins:
map = plugin.after_map(map)


map.redirect('/*(url)/', '/{url}',
_redirect_code='301 Moved Permanently')
map.connect('/*url', controller='template', action='view')
Expand Down

0 comments on commit 60b06f3

Please sign in to comment.