Skip to content

Commit

Permalink
Merge branch 'master' into cli-user
Browse files Browse the repository at this point in the history
  • Loading branch information
tino097 committed Jul 9, 2019
2 parents f031d2f + ed12c25 commit 327652f
Show file tree
Hide file tree
Showing 899 changed files with 28,331 additions and 139,710 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -23,6 +23,7 @@ tmp/*
solr_runtime/*
fl_notes.txt
*.ini
!ckan/migration/alembic.ini
.noseids
*~
.idea
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -8,7 +8,7 @@ flake8-steps: &flake8-steps
before_script:
- flake8 --version
# stop the build if there are Python syntax errors or undefined names
- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics --exclude ./ckan/include/rjsmin.py
- flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude ./ckan/include/rjsmin.py
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
script:
Expand Down
76 changes: 75 additions & 1 deletion CHANGELOG.rst
Expand Up @@ -79,6 +79,39 @@ Removals and deprecations:
dataset blueprint in CKAN>=2.9, and, in the same time, it's still working for
Pylons package controller in CKAN<2.9

v.2.8.3 2019-07-03
==================

General notes:
* Note: This version does not requires a requirements upgrade on source installations
* Note: This version does not requires a database upgrade
* Note: This version does not require a Solr schema upgrade

Fixes:

* Fix `include_total` in `datastore_search` (`#4446 <https://github.com/ckan/ckan/issues/4446>`_)
* Fix problem with reindex-fast (`#4352 <https://github.com/ckan/ckan/issues/4352>`_)
* Fix `ValueError` in `url_validator` (`#4629 <https://github.com/ckan/ckan/issues/4629>`_)
* Strip local path when uploading file in IE (`#4608 <https://github.com/ckan/ckan/issues/4608>`_)
* Increase size of h1 headings to 1.8em (`#4665 <https://github.com/ckan/ckan/issues/4665>`_)
* Fix broken div nesting in the `user/read_base.html` (`#4672 <https://github.com/ckan/ckan/issues/4672>`_)
* `package_search` parameter `fl` accepts list-like values (`#4464 <https://github.com/ckan/ckan/issues/4464>`_)
* Use `chained_auth_function` with core auth functions (`#4491 <https://github.com/ckan/ckan/issues/4491>`_)
* Allow translation of custom licenses (`#4594 <https://github.com/ckan/ckan/issues/4594>`_)
* Fix delete button links (`#4598 <https://github.com/ckan/ckan/issues/4598>`_)
* Fix hardcoded root paths (`#4662 <https://github.com/ckan/ckan/issues/4662>`_)
* Fix reCaptcha (`#4732 <https://github.com/ckan/ckan/issues/4732>`_)
* Fix incremented follower-counter (`#4767 <https://github.com/ckan/ckan/issues/4767>`_)
* Fix breadcrumb on /datasets (`#4405 <https://github.com/ckan/ckan/issues/4405>`_)
* Fix `root_path` when using mod_wsgi (`#4452 <https://github.com/ckan/ckan/issues/4452>`_)
* Correctly insert root_path for urls generated with _external flag (`#4722 <https://github.com/ckan/ckan/issues/4722>`_)
* Make reorder resources button translatable (`#4838 <https://github.com/ckan/ckan/issues/4838>`_)
* Fix `feeds` urls generation (`#4854 <https://github.com/ckan/ckan/pull/4854>`_)
* More robust auth functions for `resource_view_show` (`#4827 <https://github.com/ckan/ckan/issues/4827>`_)
* Allow to customize the DataProxy URL (`#4874 <https://github.com/ckan/ckan/issues/4874>`_)
* Allow custom CKAN callback URL for the DataPusher (`#4878 <https://github.com/ckan/ckan/issues/4878>`_)
* Add `psycopg>=2.8` support (`#4841 <https://github.com/ckan/ckan/pull/4841>`_)

v.2.8.2 2018-12-12
==================

Expand Down Expand Up @@ -252,6 +285,28 @@ Changes and deprecations:
to specify this argument explicitly, as in future it'll become required.
* The ``ckan.recaptcha.version`` config option is now removed, since v2 is the only valid version now (#4061)

v.2.7.6 2019-07-03
==================

General notes:
* Note: This version does not requires a requirements upgrade on source installations
* Note: This version does not requires a database upgrade
* Note: This version does not require a Solr schema upgrade

Fixes:

* Fix problem with reindex-fast (`#4352 <https://github.com/ckan/ckan/issues/4352>`_)
* Fix `include_total` in `datastore_search` (`#4446 <https://github.com/ckan/ckan/issues/4446>`_)
* Fix `ValueError` in `url_validator` (`#4629 <https://github.com/ckan/ckan/issues/4629>`_)
* Strip local path when uploading file in IE (`#4608 <https://github.com/ckan/ckan/issues/4608>`_)
* Increase size of h1 headings to 1.8em (`#4665 <https://github.com/ckan/ckan/issues/4665>`_)
* Fix broken div nesting in the `user/read_base.html` (`#4672 <https://github.com/ckan/ckan/issues/4672>`_)
* Use `get_action` to call activity actions (`#4684 <https://github.com/ckan/ckan/issues/4684>`_)
* Make reorder resources button translatable (`#4838 <https://github.com/ckan/ckan/issues/4838>`_)
* More robust auth functions for `resource_view_show` (`#4827 <https://github.com/ckan/ckan/issues/4827>`_)
* Allow to customize the DataProxy URL (`#4874 <https://github.com/ckan/ckan/issues/4874>`_)
* Allow custom CKAN callback URL for the DataPusher (`#4878 <https://github.com/ckan/ckan/issues/4878>`_)

v2.7.5 2018-12-12
=================

Expand Down Expand Up @@ -286,7 +341,7 @@ General notes:
This is due to a bug in the psycopg2 version pinned to the release. To solve
it, upgrade psycopg2 with the following command::

pip install --upgrade psycopg2==2.7.3.2
pip install --upgrade psycopg2==2.8.2

* This release does not require a Solr schema upgrade, but if you are having the
issues described in #3863 (datasets wrongly indexed in multilingual setups),
Expand Down Expand Up @@ -376,6 +431,7 @@ Major changes:
* Common requests code for Flask and Pylons (#3212)
* Generate complete datastore dump files (#3344)
* A new system for asynchronous background jobs (#3165)
* Chaining of action functions (#3494)

Minor changes:
* Renamed example theme plugin (#3576)
Expand Down Expand Up @@ -450,6 +506,24 @@ Deprecations:
jobs (http://docs.ckan.org/en/latest/maintaining/background-tasks.html). Extensions can still
of course use Celery but they will need to handle the management themselves.

v.2.6.8 2019-07-03
==================

General notes:
* Note: This version does not requires a requirements upgrade on source installations
* Note: This version does not requires a database upgrade
* Note: This version does not require a Solr schema upgrade

Fixes:

* Fix broken div nesting in the `user/read_base.html` (`#4672 <https://github.com/ckan/ckan/issues/4672>`_)
* Strip local path when uploading file in IE (`#4608 <https://github.com/ckan/ckan/issues/4608>`_)
* Increase size of h1 headings to 1.8em (`#4665 <https://github.com/ckan/ckan/issues/4665>`_)
* Fix `ValueError` in `url_validator` (`#4629 <https://github.com/ckan/ckan/issues/4629>`_)
* More robust auth functions for `resource_view_show` (`#4827 <https://github.com/ckan/ckan/issues/4827>`_)
* Allow to customize the DataProxy URL (`#4874 <https://github.com/ckan/ckan/issues/4874>`_)
* Allow custom CKAN callback URL for the DataPusher (`#4878 <https://github.com/ckan/ckan/issues/4878>`_)

v2.6.7 2018-12-12
=================

Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Expand Up @@ -10,6 +10,10 @@ RUN apt-get -q -y update \
python-pip \
python-virtualenv \
python-wheel \
python3-dev \
python3-pip \
python3-virtualenv \
python3-wheel \
libpq-dev \
libxml2-dev \
libxslt-dev \
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Expand Up @@ -2,7 +2,7 @@ License
+++++++

CKAN - Data Catalogue Software
Copyright (c) 2006-2018 Open Knowledge International and contributors
Copyright (c) 2006-2018 Open Knowledge Foundation and contributors

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -94,7 +94,7 @@ ckan-dev mailing list or on Gitter.
Copying and License
-------------------

This material is copyright (c) 2006-2018 Open Knowledge International and contributors.
This material is copyright (c) 2006-2018 Open Knowledge Foundation and contributors.

It is open and licensed under the GNU Affero General Public License (AGPL) v3.0
whose full text may be found at:
Expand Down
3 changes: 2 additions & 1 deletion ckan/authz.py
Expand Up @@ -206,7 +206,8 @@ def is_authorized(action, context, data_dict=None):
return {
'success': False,
'msg': 'Action {0} requires an authenticated user'.format(
action)
(auth_function if not isinstance(auth_function, functools.partial)
else auth_function.func).__name__)
}

return auth_function(context, data_dict)
Expand Down
46 changes: 46 additions & 0 deletions ckan/cli/asset.py
@@ -0,0 +1,46 @@
# encoding: utf-8

import logging

import click
from webassets import script
from webassets.exceptions import BundleError

from ckan.lib import webassets_tools
from ckan.cli import error_shout

log = logging.getLogger(__name__)


@click.group(name=u'asset', short_help=u'WebAssets commands')
def asset():
pass


@asset.command(u'build', short_help=u'Builds all bundles.')
def build():
u'''Builds bundles, regardless of whether they are changed or not.'''
script.main(['build'], webassets_tools.env)
click.secho(u'Compile assets: SUCCESS', fg=u'green', bold=True)


@asset.command(u'watch', short_help=u'Watch changes in source files.')
def watch():
u'''Start a daemon which monitors source files, and rebuilds bundles.
This can be useful during development, if building is not
instantaneous, and you are losing valuable time waiting for the
build to finish while trying to access your site.
'''
script.main(['watch'], webassets_tools.env)


@asset.command(u'clean', short_help=u'Clear cache.')
def clean():
u'''Will clear out the cache, which after a while can grow quite large.'''
try:
script.main(['clean'], webassets_tools.env)
except BundleError as e:
return error_shout(e)
click.secho(u'Clear cache: SUCCESS', fg=u'green', bold=True)
13 changes: 11 additions & 2 deletions ckan/cli/cli.py
Expand Up @@ -5,8 +5,13 @@
import click
from ckan.cli import config_tool
from ckan.cli import (
datapusher,
click_config_option, db, load_config, search_index, server,
translation, user,
asset,
datastore,
translation,
dataset,
plugin_info,
)

from ckan.config.middleware import make_app
Expand Down Expand Up @@ -34,6 +39,10 @@ def ckan(ctx, config, *args, **kwargs):
ckan.add_command(server.run)
ckan.add_command(seed.seed)
ckan.add_command(db.db)
ckan.add_command(datapusher.datapusher)
ckan.add_command(search_index.search_index)
ckan.add_command(asset.asset)
ckan.add_command(datastore.datastore)
ckan.add_command(translation.translation)
ckan.add_command(user.user)
ckan.add_command(dataset.dataset)
ckan.add_command(plugin_info.plugin_info)
101 changes: 101 additions & 0 deletions ckan/cli/datapusher.py
@@ -0,0 +1,101 @@
# encoding: utf-8

from __future__ import print_function

import logging

import click

import ckan.model as model
import ckan.plugins.toolkit as tk
import ckanext.datastore.backend as datastore_backend
from ckan.cli import error_shout

log = logging.getLogger(__name__)

question = (
u"Data in any datastore resource that isn't in their source files "
u"(e.g. data added using the datastore API) will be permanently "
u"lost. Are you sure you want to proceed?"
)
requires_confirmation = click.option(
u'--yes', u'-y', is_flag=True, help=u'Always answer yes to questions'
)


def confirm(yes):
if yes:
return
click.confirm(question, abort=True)


@click.group()
def datapusher():
u'''Perform commands in the datapusher.
'''


@datapusher.command()
@requires_confirmation
def resubmit(yes):
u'''Resubmit udated datastore resources.
'''
confirm(yes)

resource_ids = datastore_backend.get_all_resources_ids_in_datastore()
_submit(resource_ids)


@datapusher.command()
@click.argument(u'package', required=False)
@requires_confirmation
def submit(package, yes):
u'''Submits resources from package.
If no package ID/name specified, submits all resources from all
packages.
'''
confirm(yes)

if not package:
ids = tk.get_action(u'package_list')({
u'model': model,
u'ignore_auth': True
}, {})
else:
ids = [package]

for id in ids:
package_show = tk.get_action(u'package_show')
try:
pkg = package_show({
u'model': model,
u'ignore_auth': True
}, {u'id': id})
except Exception as e:
error_shout(e)
error_shout(u"Package '{}' was not found".format(package))
raise click.Abort()
if not pkg[u'resources']:
continue
resource_ids = [r[u'id'] for r in pkg[u'resources']]
_submit(resource_ids)


def _submit(resources):
click.echo(u'Submitting {} datastore resources'.format(len(resources)))
user = tk.get_action(u'get_site_user')({
u'model': model,
u'ignore_auth': True
}, {})
datapusher_submit = tk.get_action(u'datapusher_submit')
for id in resources:
click.echo(u'Submitting {}...'.format(id), nl=False)
data_dict = {
u'resource_id': id,
u'ignore_hash': True,
}
if datapusher_submit({u'user': user[u'name']}, data_dict):
click.echo(u'OK')
else:
click.echo(u'Fail')

0 comments on commit 327652f

Please sign in to comment.