diff --git a/ckanext/validation/cli.py b/ckanext/validation/cli.py index 5a68627d..290dcbf9 100644 --- a/ckanext/validation/cli.py +++ b/ckanext/validation/cli.py @@ -1,4 +1,4 @@ -import sys +# encoding: utf-8 import click @@ -11,11 +11,12 @@ def get_commands(): @click.group() def validation(): - """Harvests remotely mastered metadata.""" + """Validation management commands. + """ pass -@validation.command() +@validation.command(name='init-db') def init_db(): """ Initialize database tables. """ diff --git a/ckanext/validation/controller.py b/ckanext/validation/controller.py index 91224649..b4396a21 100644 --- a/ckanext/validation/controller.py +++ b/ckanext/validation/controller.py @@ -1,39 +1,11 @@ # encoding: utf-8 -from ckantoolkit import ( - BaseController, c, NotAuthorized, ObjectNotFound, - abort, _, render, get_action) +from ckantoolkit import BaseController + +from ckanext.validation import common class ValidationController(BaseController): def validation(self, resource_id): - - try: - validation = get_action(u'resource_validation_show')( - {u'user': c.user}, - {u'resource_id': resource_id}) - - resource = get_action(u'resource_show')( - {u'user': c.user}, - {u'id': resource_id}) - - dataset = get_action(u'package_show')( - {u'user': c.user}, - {u'id': resource[u'package_id']}) - - # Needed for core resource templates - c.package = c.pkg_dict = dataset - c.resource = resource - - return render(u'validation/validation_read.html', extra_vars={ - u'validation': validation, - u'resource': resource, - u'dataset': dataset, - }) - - except NotAuthorized: - abort(403, _(u'Unauthorized to read this validation report')) - except ObjectNotFound: - - abort(404, _(u'No validation report exists for this resource')) + return common.validation(resource_id)