Skip to content

Commit

Permalink
Merge branch '2375-demo-theme-development' into 2302-simple-themes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Jul 25, 2012
2 parents 5e105cc + 19de45d commit 032b9ac
Show file tree
Hide file tree
Showing 82 changed files with 2,160 additions and 978 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.txt
Expand Up @@ -23,6 +23,22 @@ v1.8
* [#2345] New action API reference docs. The documentation for CKAN's Action
API has been rewritten, with each function and its arguments and return
values now individually documented.
* Template helper functions are now restricted by default. This is
part of a process of refactoring the CKAN code. By default only
those helper functions listed in lib.helpers.__allowed_functions__
are available to templates. The full functions can still be made
available by `setting ckan.restrict_template_vars = false` in your
.ini config file. Only restricted functions will be allowed in
future versions of CKAN.

API changes and deprecation:
* [#2313] Deprecated functions related to the old faceting data structure have
been removed: `helpers.py:facet_items()`, `facets.html:facet_sidebar()`,
`facets.html:facet_list_items()`.
Internal use of the old facets datastructure (attached to the context,
`c.facets`) has been superseded by use of the improved facet data structure,
`c.search_facets`. The old data structure is still available on `c.facets`,
but is deprecated, and will be removed in v1.9.

v1.7.1 2012-06-20
=================
Expand Down
6 changes: 3 additions & 3 deletions LICENSE.txt
Expand Up @@ -22,9 +22,9 @@ Note
====

CKAN is sometimes packaged directly with other software (listed in
requires/lucid_conflict.txt). In these cases, we are required to list the
licenses of the packaged softare too. They are all AGPL compatible and read as
follows in the next sections.
pip-requirements.txt, pip-requirements-test.txt and pip-requirements-docs.txt).
In these cases, we are required to list the licenses of the packaged softare
too. They are all AGPL compatible and read as follows in the next sections.

WebHelpers
----------
Expand Down
4 changes: 2 additions & 2 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -146,9 +146,9 @@ ckan.dump_dir = %(here)s/dump
ckan.backup_dir = %(here)s/backup

# Default authorizations for new domain objects
#ckan.default_roles.Package = {"visitor": ["editor"], "logged_in": ["editor"]}
#ckan.default_roles.Package = {"visitor": ["reader"], "logged_in": ["reader"]}
#ckan.default_roles.Group = {"visitor": ["reader"], "logged_in": ["reader"]}
#ckan.default_roles.System = {"visitor": ["anon_editor"], "logged_in": ["editor"]}
#ckan.default_roles.System = {"visitor": ["reader"], "logged_in": ["editor"]}
#ckan.default_roles.AuthorizationGroup = {"visitor": ["reader"], "logged_in": ["reader"]}

## Ckan public and private recaptcha keys [localhost]
Expand Down
10 changes: 8 additions & 2 deletions ckan/config/environment.py
Expand Up @@ -36,7 +36,7 @@ class _Helpers(object):
not been enabled. '''
def __init__(self, helpers, restrict=True):
functions = {}
allowed = helpers.__allowed_functions__
allowed = helpers.__allowed_functions__[:]
# list of functions due to be deprecated
self.deprecated = []

Expand All @@ -46,8 +46,14 @@ def __init__(self, helpers, restrict=True):
if restrict:
continue
functions[helper] = getattr(helpers, helper)
if helper in allowed:
allowed.remove(helper)
self.functions = functions

if allowed:
raise Exception('Template helper function(s) `%s` not defined'
% ', '.join(allowed))

# extend helper functions with ones supplied by plugins
extra_helpers = []
for plugin in p.PluginImplementations(p.ITemplateHelpers):
Expand Down Expand Up @@ -133,7 +139,7 @@ def find_controller(self, controller):

# Load the synchronous search plugin, unless already loaded or
# explicitly disabled
if not 'synchronous_search' in config.get('ckan.plugins') and \
if not 'synchronous_search' in config.get('ckan.plugins',[]) and \
asbool(config.get('ckan.search.automatic_indexing', True)):
log.debug('Loading the synchronous search plugin')
p.load('synchronous_search')
Expand Down
8 changes: 7 additions & 1 deletion ckan/controllers/group.py
Expand Up @@ -7,6 +7,7 @@
from ckan.lib.base import ValidationException, abort, gettext
from pylons.i18n import get_lang, _
from ckan.lib.helpers import Page
import ckan.lib.maintain as maintain
from ckan.lib.navl.dictization_functions import DataError, unflatten, validate
from ckan.logic import NotFound, NotAuthorized, ValidationError
from ckan.logic import check_access, get_action
Expand Down Expand Up @@ -201,7 +202,12 @@ def pager_url(q=None, page=None):
item_count=query['count'],
items_per_page=limit
)

c.facets = query['facets']
maintain.deprecate_context_item(
'facets',
'Use `c.search_facets` instead.')

c.search_facets = query['search_facets']
c.facet_titles = {'groups': _('Groups'),
'tags': _('Tags'),
Expand Down Expand Up @@ -249,7 +255,7 @@ def new(self, data=None, errors=None, error_summary=None):
vars = {'data': data, 'errors': errors,
'error_summary': error_summary, 'action': 'new'}

self._setup_template_variables(context, data)
self._setup_template_variables(context, data, group_type=group_type)
c.form = render(self._group_form(group_type=group_type),
extra_vars=vars)
return render(self._new_template(group_type))
Expand Down
13 changes: 11 additions & 2 deletions ckan/controllers/home.py
Expand Up @@ -4,6 +4,7 @@
import sqlalchemy.exc

import ckan.logic
import ckan.lib.maintain as maintain
from ckan.lib.search import SearchError
from ckan.lib.base import *
from ckan.lib.helpers import url_for
Expand Down Expand Up @@ -54,7 +55,14 @@ def index(self):
c.search_facets = query['search_facets']
c.package_count = query['count']
c.datasets = query['results']

c.facets = query['facets']
maintain.deprecate_context_item(
'facets',
'Use `c.search_facets` instead.')

c.search_facets = query['search_facets']

c.facet_titles = {'groups': _('Groups'),
'tags': _('Tags'),
'res_format': _('Formats'),
Expand All @@ -63,8 +71,9 @@ def index(self):
data_dict = {'order_by': 'packages', 'all_fields': 1}
# only give the terms to group dictize that are returned in the
# facets as full results take a lot longer
if 'groups' in c.facets:
data_dict['groups'] = c.facets['groups'].keys()
if 'groups' in c.search_facets:
data_dict['groups'] = [ item['name'] for item in
c.search_facets['groups']['items'] ]
c.groups = ckan.logic.get_action('group_list')(context, data_dict)
except SearchError, se:
c.package_count = 0
Expand Down
31 changes: 27 additions & 4 deletions ckan/controllers/package.py
Expand Up @@ -15,6 +15,7 @@
model,
abort, h, g, c)
from ckan.lib.base import response, redirect, gettext
import ckan.lib.maintain as maintain
from ckan.lib.package_saver import PackageSaver, ValidationException
from ckan.lib.navl.dictization_functions import DataError, unflatten, validate
from ckan.lib.helpers import json
Expand Down Expand Up @@ -93,6 +94,13 @@ def _guess_package_type(self, expecting_name=False):
Guess the type of package from the URL handling the case
where there is a prefix on the URL (such as /data/package)
"""

# Special case: if the rot URL '/' has been redirected to the package
# controller (e.g. by an IRoutes extension) then there's nothing to do
# here.
if request.path == '/':
return 'dataset'

parts = [x for x in request.path.split('/') if x]

idx = -1
Expand Down Expand Up @@ -238,6 +246,9 @@ def pager_url(q=None, page=None):
'res_format': _('Formats'),
'license': _('Licence'), }

maintain.deprecate_context_item(
'facets',
'Use `c.search_facets` instead.')
return render(self._search_template(package_type))

def _content_type_from_extension(self, ext):
Expand Down Expand Up @@ -444,9 +455,8 @@ def new(self, data=None, errors=None, error_summary=None):
return self._save_new(context)

data = data or clean_dict(unflatten(tuplize_dict(parse_params(
request.params, ignore_keys=CACHE_PARAMETERS))))
request.POST, ignore_keys=CACHE_PARAMETERS))))
c.resources_json = json.dumps(data.get('resources', []))

# convert tags if not supplied in data
if data and not data.get('tag_string'):
data['tag_string'] = ', '.join(
Expand All @@ -462,6 +472,11 @@ def new(self, data=None, errors=None, error_summary=None):
elif data.get('state') == 'draft-complete':
stage = ['active', 'complete', 'complete']

# if we are creating from a group then this allows the group to be
# set automatically
data['group_id'] = request.params.get('group') or \
request.params.get('groups__0__id')

vars = {'data': data, 'errors': errors,
'error_summary': error_summary,
'action': 'new', 'stage': stage}
Expand Down Expand Up @@ -894,7 +909,11 @@ def _save_new(self, context, package_type=None):
except DataError:
abort(400, _(u'Integrity Error'))
except SearchIndexError, e:
abort(500, _(u'Unable to add package to search index.'))
try:
exc_str = unicode(repr(e.args))
except Exception: # We don't like bare excepts
exc_str = unicode(str(e))
abort(500, _(u'Unable to add package to search index.') + exc_str)
except ValidationError, e:
errors = e.error_dict
error_summary = e.error_summary
Expand Down Expand Up @@ -942,7 +961,11 @@ def _save_edit(self, name_or_id, context):
except DataError:
abort(400, _(u'Integrity Error'))
except SearchIndexError, e:
abort(500, _(u'Unable to update search index.'))
try:
exc_str = unicode(repr(e.args))
except Exception: # We don't like bare excepts
exc_str = unicode(str(e))
abort(500, _(u'Unable to update search index.') + exc_str)
except ValidationError, e:
errors = e.error_dict
error_summary = e.error_summary
Expand Down
5 changes: 5 additions & 0 deletions ckan/controllers/revision.py
Expand Up @@ -65,6 +65,11 @@ def list(self):
revision_changes[model.ResourceGroup]
package_extra_revisions = revision_changes[model.PackageExtra]
for package in revision.packages:
if not package:
# package is None sometimes - I don't know why,
# but in the meantime while that is fixed,
# avoid an exception here
continue
number = len(package.all_revisions)
package_revision = None
count = 0
Expand Down

0 comments on commit 032b9ac

Please sign in to comment.