diff --git a/README.rst b/README.rst index 6f45f30f68a..f1c0596a8ce 100644 --- a/README.rst +++ b/README.rst @@ -74,7 +74,7 @@ others, make a new page on the `CKAN wiki`_, and tell us about it on Copying and License ------------------- -This material is copyright (c) 2006-2014 Open Knowledge Foundation. +This material is copyright (c) 2006-2017 Open Knowledge International and contributors. It is open and licensed under the GNU Affero General Public License (AGPL) v3.0 whose full text may be found at: diff --git a/ckan/config/deployment.ini_tmpl b/ckan/config/deployment.ini_tmpl index 3fdafe747e2..fe59cdb0f6d 100644 --- a/ckan/config/deployment.ini_tmpl +++ b/ckan/config/deployment.ini_tmpl @@ -159,6 +159,7 @@ ckan.feeds.author_link = #ckan.datapusher.formats = csv xls xlsx tsv application/csv application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet #ckan.datapusher.url = http://127.0.0.1:8800/ +#ckan.datapusher.assume_task_stale_after = 3600 # Resource Proxy settings # Preview size limit, default: 1MB diff --git a/ckan/config/middleware/flask_app.py b/ckan/config/middleware/flask_app.py index 2bbfad33f54..8ec436e8158 100644 --- a/ckan/config/middleware/flask_app.py +++ b/ckan/config/middleware/flask_app.py @@ -1,7 +1,6 @@ # encoding: utf-8 import os -import importlib import inspect import itertools import pkgutil @@ -13,7 +12,6 @@ from werkzeug.exceptions import HTTPException from werkzeug.routing import Rule -from flask_debugtoolbar import DebugToolbarExtension from beaker.middleware import SessionMiddleware from paste.deploy.converters import asbool @@ -70,6 +68,7 @@ def make_flask_stack(conf, **app_conf): ' with the SECRET_KEY config option') if debug: + from flask_debugtoolbar import DebugToolbarExtension app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False DebugToolbarExtension(app) diff --git a/ckan/controllers/group.py b/ckan/controllers/group.py index e711fea8561..40b7ef2b5b3 100644 --- a/ckan/controllers/group.py +++ b/ckan/controllers/group.py @@ -382,13 +382,16 @@ def bulk_process(self, id): data_dict = {'id': id, 'type': group_type} try: + self._check_access('bulk_update_public', context, {'org_id': id}) # Do not query for the group datasets when dictizing, as they will # be ignored and get requested on the controller anyway data_dict['include_datasets'] = False c.group_dict = self._action('group_show')(context, data_dict) c.group = context['group'] - except (NotFound, NotAuthorized): + except NotFound: abort(404, _('Group not found')) + except NotAuthorized: + abort(403, _('User %r not authorized to edit %s') % (c.user, id)) if not c.group_dict['is_organization']: # FIXME: better error @@ -634,14 +637,21 @@ def members(self, id): 'user': c.user} try: + data_dict = {'id': id} + check_access('group_edit_permissions', context, data_dict) c.members = self._action('member_list')( context, {'id': id, 'object_type': 'user'} ) - data_dict = {'id': id} data_dict['include_datasets'] = False c.group_dict = self._action('group_show')(context, data_dict) - except (NotFound, NotAuthorized): + except NotFound: abort(404, _('Group not found')) + except NotAuthorized: + abort( + 403, + _('User %r not authorized to edit members of %s') % ( + c.user, id)) + return self._render_template('group/members.html', group_type) def member_new(self, id): diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py index 777bda5fa5e..4621b994296 100644 --- a/ckan/controllers/package.py +++ b/ckan/controllers/package.py @@ -390,11 +390,14 @@ def read(self, id): try: return render(template, extra_vars={'dataset_type': package_type}) - except ckan.lib.render.TemplateNotFound: - msg = _("Viewing {package_type} datasets in {format} format is " - "not supported (template file {file} not found).".format( - package_type=package_type, format=format, - file=template)) + except ckan.lib.render.TemplateNotFound as e: + msg = _( + "Viewing datasets of type \"{package_type}\" is " + "not supported ({file_!r}).".format( + package_type=package_type, + file_=e.message + ) + ) abort(404, msg) assert False, "We should never get here" diff --git a/ckan/lib/cli.py b/ckan/lib/cli.py index 3cc819fed70..4dad4d00721 100644 --- a/ckan/lib/cli.py +++ b/ckan/lib/cli.py @@ -20,6 +20,7 @@ import paste.script from paste.registry import Registry from paste.script.util.logging_config import fileConfig +import click import ckan.logic as logic import ckan.model as model @@ -85,6 +86,54 @@ def parse_db_config(config_key='sqlalchemy.url'): return db_details +def user_add(args): + '''Add new user if we use paster sysadmin add + or paster user add + ''' + if len(args) < 2: + error('Need name and email of the user.') + username = args[0] + + # parse args into data_dict + data_dict = {'name': username} + for arg in args[1:]: + try: + field, value = arg.split('=', 1) + data_dict[field] = value + except ValueError: + raise ValueError( + 'Could not parse arg: %r (expected "