Permalink
Browse files

Merge branch 'master' into 2375-demo-theme-development

Conflicts:
	ckan/controllers/home.py
index() c.facets deprecated in master and c.facet_titles from demo branch

	ckan/lib/base.py
minor merge differences passing renderer parameter

	ckan/lib/dictization/model_dictize.py
format fixes and url corrections in resource dictize merged

	ckan/lib/helpers.py
new functions in both branches plus one removed from master

	ckan/logic/__init__.py
better tag error handeling from master

	ckan/templates/package/resource_read.html
    ckan/templates/user/edit_user_form.html

templates have changed
  • Loading branch information...
2 parents b31109b + b4e5cec commit 1a743abeffa5cfb1c9b1b39a0f437b8f1b65cf1b @tobes tobes committed Jul 25, 2012
Showing with 1,208 additions and 783 deletions.
  1. +16 −0 CHANGELOG.txt
  2. +3 −3 LICENSE.txt
  3. +2 −2 ckan/config/deployment.ini_tmpl
  4. +8 −2 ckan/config/environment.py
  5. +7 −1 ckan/controllers/group.py
  6. +11 −2 ckan/controllers/home.py
  7. +21 −2 ckan/controllers/package.py
  8. +5 −0 ckan/controllers/revision.py
  9. +85 −66 ckan/lib/base.py
  10. +22 −12 ckan/lib/cli.py
  11. +1 −1 ckan/lib/dictization/__init__.py
  12. +4 −0 ckan/lib/dictization/model_dictize.py
  13. +11 −5 ckan/lib/dictization/model_save.py
  14. +15 −29 ckan/lib/helpers.py
  15. +33 −0 ckan/lib/maintain.py
  16. +0 −1 ckan/lib/navl/dictization_functions.py
  17. +1 −1 ckan/lib/search/query.py
  18. +4 −1 ckan/logic/__init__.py
  19. +9 −3 ckan/logic/action/create.py
  20. +59 −17 ckan/logic/action/get.py
  21. +16 −8 ckan/logic/action/update.py
  22. +2 −0 ckan/logic/auth/publisher/get.py
  23. +1 −0 ckan/logic/schema.py
  24. +2 −2 ckan/model/authz.py
  25. +102 −80 ckan/model/group.py
  26. +203 −201 ckan/model/license.py
  27. +1 −1 ckan/model/meta.py
  28. +1 −1 ckan/new_authz.py
  29. +1 −2 ckan/public/scripts/application.js
  30. +1 −1 ckan/templates/package/resource_read.html
  31. +30 −0 ckan/templates/snippets/internal-tracking.html
  32. +0 −88 ckan/templates_legacy/facets.html
  33. +1 −23 ckan/templates_legacy/layout_base.html
  34. +4 −4 ckan/tests/forms/test_authz.py
  35. +66 −44 ckan/tests/functional/api/test_activity.py
  36. +2 −2 ckan/tests/functional/test_admin.py
  37. +1 −1 ckan/tests/functional/test_authz.py
  38. +100 −6 ckan/tests/functional/test_group.py
  39. +2 −1 ckan/tests/functional/test_home.py
  40. +67 −82 ckan/tests/functional/test_package.py
  41. +24 −43 ckan/tests/functional/test_package_edit_authz.py
  42. +15 −5 ckan/tests/functional/test_publisher_auth.py
  43. +0 −7 ckan/tests/functional/test_search.py
  44. +14 −2 ckan/tests/functional/test_storage.py
  45. +2 −3 ckan/tests/functional/test_upload.py
  46. +8 −8 ckan/tests/lib/test_dictization.py
  47. +7 −6 ckan/tests/logic/test_action.py
  48. +15 −7 ckan/tests/models/test_authz.py
  49. +2 −2 ckan/tests/models/test_repo.py
  50. +47 −0 ckan/tests/models/test_user.py
  51. +3 −3 ckanext/organizations/forms.py
  52. +2 −2 ckanext/publisher_form/templates/publisher_read.html
  53. +1 −0 doc/index.rst
  54. +148 −0 doc/toolkit.rst
View
@@ -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
=================
View
@@ -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
----------
@@ -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]
@@ -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 = []
@@ -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):
@@ -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')
@@ -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
@@ -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'),
@@ -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))
@@ -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
@@ -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'),
@@ -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
@@ -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
@@ -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
@@ -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):
@@ -898,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
@@ -946,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
@@ -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
Oops, something went wrong.

0 comments on commit 1a743ab

Please sign in to comment.