Skip to content

Commit

Permalink
Merge branch 'release-datagov' into release-datagov-saml2
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/logic/auth/__init__.py
    IAuthenticator fixes
  • Loading branch information
tobes committed Apr 19, 2013
2 parents e0e60c1 + 54adb2f commit ce94d35
Show file tree
Hide file tree
Showing 25 changed files with 242 additions and 217 deletions.
28 changes: 12 additions & 16 deletions CONTRIBUTING.rst
Expand Up @@ -5,17 +5,23 @@ Contributing to CKAN
.. _CKAN repo on GitHub: https://github.com/okfn/ckan
.. _CKAN issue tracker: https://github.com/okfn/ckan/issues
.. _docs.ckan.org: http://docs.ckan.org
.. _Contributing to CKAN's Documentation: https://github.com/okfn/ckan/blob/master/CONTRIBUTING.rst#contributing-to-ckans-documentation

(This section is about contributing code, if you want to contribute
documentation see `Contributing to CKAN's Documentation`_.)
documentation see `Contributing to the CKAN Documentation`_.)

CKAN is a free software project and code contributions are welcome. To
contribute code to CKAN you should fork CKAN to your own GitHub account, push
your code to a feature branch on your fork, then make a pull request for your
branch on the central CKAN repo. We'll go through each step in detail below...


Coding Standards
----------------

When writing code for CKAN, try to follow our
`coding standards <http://docs.ckan.org/en/latest/#for-ckan-developers>`_.


Fork CKAN on GitHub
-------------------

Expand Down Expand Up @@ -114,11 +120,8 @@ When submitting a pull request:
see `Feature Branches`_.
- Your branch should contain new or changed tests for any new or changed
code.
- Your branch should contain updates to the
`CHANGELOG file <https://github.com/okfn/ckan/blob/master/CHANGELOG.txt>`_
briefly summarising your code changes.
- Your branch should contain new or updated documentation for any new or
updated code, see `Contributing to CKAN's Documentation`_.
updated code, see `Contributing to the CKAN Documentation`_.
- Your branch should be up to date with the master branch of the central
CKAN repo, see `Keeping Up with master`_.
- All the CKAN tests should pass on your branch, see
Expand All @@ -133,16 +136,9 @@ When merging a feature or bug branch into master:
- Use the ``--no-ff`` option in the ``git merge`` command,


Coding Standards
----------------

When writing code for CKAN, try to follow our
`coding standards <http://docs.ckan.org/en/latest/#for-ckan-developers>`_.


====================================
Contributing to CKAN's Documentation
====================================
======================================
Contributing to the CKAN Documentation
======================================

Note: getting started with contributing to `docs.ckan.org`_ is a little
complicated. An easier way to contribute documentation to CKAN is to
Expand Down
163 changes: 83 additions & 80 deletions ckan/config/routing.py
Expand Up @@ -69,14 +69,13 @@ def make_map():
# import controllers here rather than at root level because
# pylons config is initialised by this point.


# Helpers to reduce code clutter
GET = dict(method=['GET'])
PUT = dict(method=['PUT'])
POST = dict(method=['POST'])
DELETE = dict(method=['DELETE'])
GET_POST = dict(method=['GET', 'POST'])
PUT_POST = dict(method=['PUT','POST'])
PUT_POST = dict(method=['PUT', 'POST'])
PUT_POST_DELETE = dict(method=['PUT', 'POST', 'DELETE'])
OPTIONS = dict(method=['OPTIONS'])

Expand All @@ -93,7 +92,8 @@ 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=OPTIONS)
map.connect('*url', controller='home', action='cors_options',
conditions=OPTIONS)

# CUSTOM ROUTES HERE
for plugin in routing_plugins:
Expand All @@ -104,39 +104,43 @@ def make_map():

# CKAN API versioned.
register_list = [
'package',
'dataset',
'resource',
'tag',
'group',
'related',
'revision',
'licenses',
'rating',
'user',
'activity'
]
'package',
'dataset',
'resource',
'tag',
'group',
'related',
'revision',
'licenses',
'rating',
'user',
'activity'
]
register_list_str = '|'.join(register_list)

# /api ver 3 or none
with SubMapper(map, controller='api', path_prefix='/api{ver:/3|}', ver='/3') as m:
with SubMapper(map, controller='api', path_prefix='/api{ver:/3|}',
ver='/3') as m:
m.connect('/action/{logic_function}', action='action',
conditions=GET_POST)

# /api ver 1, 2, 3 or none
with SubMapper(map, controller='api', path_prefix='/api{ver:/1|/2|/3|}', ver='/1') as m:
with SubMapper(map, controller='api', path_prefix='/api{ver:/1|/2|/3|}',
ver='/1') as m:
m.connect('', action='get_api')
m.connect('/search/{register}', action='search')

# /api ver 1, 2 or none
with SubMapper(map, controller='api', path_prefix='/api{ver:/1|/2|}', ver='/1') as m:
with SubMapper(map, controller='api', path_prefix='/api{ver:/1|/2|}',
ver='/1') as m:
m.connect('/tag_counts', action='tag_counts')
m.connect('/rest', action='index')
m.connect('/qos/throughput/', action='throughput', conditions=GET)

# /api/rest ver 1, 2 or none
with SubMapper(map, controller='api', path_prefix='/api{ver:/1|/2|}', ver='/1',
requirements=dict(register=register_list_str)) as m:
with SubMapper(map, controller='api', path_prefix='/api{ver:/1|/2|}',
ver='/1', requirements=dict(register=register_list_str)
) as m:

m.connect('/rest/{register}', action='list', conditions=GET)
m.connect('/rest/{register}', action='create', conditions=POST)
Expand All @@ -145,20 +149,21 @@ def make_map():
m.connect('/rest/{register}/{id}', action='update', conditions=POST)
m.connect('/rest/{register}/{id}', action='delete', conditions=DELETE)
m.connect('/rest/{register}/{id}/:subregister', action='list',
conditions=GET)
conditions=GET)
m.connect('/rest/{register}/{id}/:subregister', action='create',
conditions=POST)
conditions=POST)
m.connect('/rest/{register}/{id}/:subregister/{id2}', action='create',
conditions=POST)
conditions=POST)
m.connect('/rest/{register}/{id}/:subregister/{id2}', action='show',
conditions=GET)
conditions=GET)
m.connect('/rest/{register}/{id}/:subregister/{id2}', action='update',
conditions=PUT)
conditions=PUT)
m.connect('/rest/{register}/{id}/:subregister/{id2}', action='delete',
conditions=DELETE)
conditions=DELETE)

# /api/util ver 1, 2 or none
with SubMapper(map, controller='api', path_prefix='/api{ver:/1|/2|}', ver='/1') as m:
with SubMapper(map, controller='api', path_prefix='/api{ver:/1|/2|}',
ver='/1') as m:
m.connect('/util/user/autocomplete', action='user_autocomplete')
m.connect('/util/is_slug_valid', action='is_slug_valid',
conditions=GET)
Expand Down Expand Up @@ -190,7 +195,7 @@ def make_map():
map.redirect('/package/{url:.*}', '/dataset/{url}')

with SubMapper(map, controller='related') as m:
m.connect('related_new', '/dataset/{id}/related/new', action='new')
m.connect('related_new', '/dataset/{id}/related/new', action='new')
m.connect('related_edit', '/dataset/{id}/related/edit/{related_id}',
action='edit')
m.connect('related_delete', '/dataset/{id}/related/delete/{related_id}',
Expand All @@ -205,35 +210,32 @@ def make_map():
highlight_actions='index search')
m.connect('add dataset', '/dataset/new', action='new')
m.connect('/dataset/{action}',
requirements=dict(action='|'.join([
'list',
'autocomplete',
'search'
]))
)
requirements=dict(action='|'.join([
'list',
'autocomplete',
'search'
])))

m.connect('/dataset/{action}/{id}/{revision}', action='read_ajax',
requirements=dict(action='|'.join([
'read',
'edit',
'history',
]))
)
requirements=dict(action='|'.join([
'read',
'edit',
'history',
])))
m.connect('/dataset/{action}/{id}',
requirements=dict(action='|'.join([
'edit',
'new_metadata',
'new_resource',
'history',
'read_ajax',
'history_ajax',
'follow',
'activity',
'unfollow',
'delete',
'api_data',
]))
)
requirements=dict(action='|'.join([
'edit',
'new_metadata',
'new_resource',
'history',
'read_ajax',
'history_ajax',
'follow',
'activity',
'unfollow',
'delete',
'api_data',
])))
m.connect('dataset_followers', '/dataset/followers/{id}',
action='followers', ckan_icon='group')
m.connect('dataset_activity', '/dataset/activity/{id}',
Expand All @@ -253,7 +255,8 @@ def make_map():
m.connect('/dataset/{id}/resource/{resource_id}/embed',
action='resource_embedded_dataviewer')
m.connect('/dataset/{id}/resource/{resource_id}/viewer',
action='resource_embedded_dataviewer', width="960", height="800")
action='resource_embedded_dataviewer', width="960",
height="800")
m.connect('/dataset/{id}/resource/{resource_id}/preview',
action='resource_datapreview')

Expand All @@ -271,22 +274,21 @@ def make_map():
m.connect('group_index', '/group', action='index',
highlight_actions='index search')
m.connect('group_list', '/group/list', action='list')
m.connect('group_new', '/group/new', action='new')
m.connect('group_new', '/group/new', action='new')
m.connect('group_action', '/group/{action}/{id}',
requirements=dict(action='|'.join([
'edit',
'delete',
'members',
'member_new',
'member_delete',
'history',
'followers',
'follow',
'unfollow',
'admins',
'activity',
]))
)
requirements=dict(action='|'.join([
'edit',
'delete',
'members',
'member_new',
'member_delete',
'history',
'followers',
'follow',
'unfollow',
'admins',
'activity',
])))
m.connect('group_about', '/group/about/{id}', action='about',
ckan_icon='info-sign'),
m.connect('group_activity', '/group/activity/{id}/{offset}',
Expand All @@ -300,14 +302,13 @@ def make_map():
m.connect('/organization/list', action='list')
m.connect('/organization/new', action='new')
m.connect('/organization/{action}/{id}',
requirements=dict(action='|'.join([
'delete',
'admins',
'member_new',
'member_delete',
'history'
]))
)
requirements=dict(action='|'.join([
'delete',
'admins',
'member_new',
'member_delete',
'history'
])))
m.connect('organization_activity', '/organization/activity/{id}',
action='activity', ckan_icon='time')
m.connect('organization_read', '/organization/{id}', action='read')
Expand All @@ -319,15 +320,17 @@ def make_map():
action='edit', ckan_icon='edit')
m.connect('organization_members', '/organization/members/{id}',
action='members', ckan_icon='group')
m.connect('organization_bulk_process', '/organization/bulk_process/{id}',
m.connect('organization_bulk_process',
'/organization/bulk_process/{id}',
action='bulk_process', ckan_icon='sitemap')
register_package_plugins(map)
register_group_plugins(map)

# tags
map.redirect('/tags', '/tag')
map.redirect('/tags/{url:.*}', '/tag/{url}')
map.redirect('/tag/read/{url:.*}', '/tag/{url}', _redirect_code='301 Moved Permanently')
map.redirect('/tag/read/{url:.*}', '/tag/{url}',
_redirect_code='301 Moved Permanently')
map.connect('/tag', controller='tag', action='index')
map.connect('/tag/{id}', controller='tag', action='read')
# users
Expand Down
1 change: 0 additions & 1 deletion ckan/controllers/error.py
Expand Up @@ -10,7 +10,6 @@


class ErrorController(BaseController):

"""Generates error documents as and when they are required.
The ErrorDocuments middleware forwards to ErrorController when error
Expand Down
16 changes: 6 additions & 10 deletions ckan/controllers/feed.py
Expand Up @@ -152,7 +152,6 @@ def _create_atom_id(resource_path, authority_name=None, date_string=None):


class FeedController(BaseController):

base_url = config.get('ckan.site_url')

def _alternate_url(self, params, **kwargs):
Expand Down Expand Up @@ -207,7 +206,6 @@ def group(self, id):
navigation_urls=navigation_urls)

def tag(self, id):

data_dict, params = self._parse_url_params()
data_dict['fq'] = 'tags:"%s"' % id

Expand Down Expand Up @@ -323,7 +321,6 @@ def custom(self):

def output_feed(self, results, feed_title, feed_description,
feed_link, feed_url, navigation_urls, feed_guid):

author_name = config.get('ckan.feeds.author_name', '').strip() or \
config.get('ckan.site_id', '').strip()
author_link = config.get('ckan.feeds.author_link', '').strip() or \
Expand All @@ -349,8 +346,8 @@ def output_feed(self, results, feed_title, feed_description,
feed.add_item(
title=pkg.get('title', ''),
link=self.base_url + h.url_for(controller='package',
action='read',
id=pkg['id']),
action='read',
id=pkg['id']),
description=pkg.get('notes', ''),
updated=h.date_str_to_datetime(pkg.get('metadata_modified')),
published=h.date_str_to_datetime(pkg.get('metadata_created')),
Expand All @@ -360,10 +357,10 @@ def output_feed(self, results, feed_title, feed_description,
categories=[t['name'] for t in pkg.get('tags', [])],
enclosure=webhelpers.feedgenerator.Enclosure(
self.base_url + h.url_for(controller='api',
register='package',
action='show',
id=pkg['name'],
ver='2'),
register='package',
action='show',
id=pkg['name'],
ver='2'),
unicode(len(json.dumps(pkg))), # TODO fix this
u'application/json')
)
Expand Down Expand Up @@ -433,7 +430,6 @@ def _parse_url_params(self):
Returns the constructed search-query dict, and the valid URL
query parameters.
"""

try:
page = int(request.params.get('page', 1)) or 1
except ValueError:
Expand Down

0 comments on commit ce94d35

Please sign in to comment.