From 1b6e26f5ce65886e2b5dea4ee463a4f009b8a493 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Fri, 13 Dec 2019 16:44:52 +0200 Subject: [PATCH] IClick support --- ckanext/googleanalytics/cli.py | 16 ++++++++-------- ckanext/googleanalytics/plugin/flask_plugin.py | 8 +++++++- setup.py | 3 --- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ckanext/googleanalytics/cli.py b/ckanext/googleanalytics/cli.py index 52533c2..e8f4dc8 100644 --- a/ckanext/googleanalytics/cli.py +++ b/ckanext/googleanalytics/cli.py @@ -10,8 +10,6 @@ import ckan.model as model from . import dbutil -from ckan.cli import error_shout, click_config_option -from ckan.cli.cli import CkanCommand import ckan.plugins.toolkit as tk log = logging.getLogger(__name__) @@ -22,14 +20,16 @@ RESOURCE_URL_REGEX = re.compile("/dataset/[a-z0-9-_]+/resource/([a-z0-9-_]+)") DATASET_EDIT_REGEX = re.compile("/dataset/edit/([a-z0-9-_]+)") -@click.group(short_help=u"GoogleAnalytics commands") -@click.help_option(u"-h", u"--help") -@click_config_option -@click.pass_context -def googleanalytics(ctx, config, *args, **kwargs): - ctx.obj = CkanCommand(config) +def get_commands(): + return [ + googleanalytics + ] +@click.group(short_help=u"GoogleAnalytics commands") +def googleanalytics(): + pass + @googleanalytics.command() def init(): """Initialise the local stats database tables diff --git a/ckanext/googleanalytics/plugin/flask_plugin.py b/ckanext/googleanalytics/plugin/flask_plugin.py index 08e3fc7..74b4c51 100644 --- a/ckanext/googleanalytics/plugin/flask_plugin.py +++ b/ckanext/googleanalytics/plugin/flask_plugin.py @@ -7,10 +7,11 @@ import queue import ckan.plugins as plugins from ckanext.googleanalytics.views import ga - +from ckanext.googleanalytics.cli import get_commands class GAMixinPlugin(plugins.SingletonPlugin): plugins.implements(plugins.IBlueprint) + plugins.implements(plugins.IClick) analytics_queue = queue.Queue() @@ -18,3 +19,8 @@ class GAMixinPlugin(plugins.SingletonPlugin): def get_blueprint(self): return [ga] + + # IClick + + def get_commands(self): + return get_commands() diff --git a/setup.py b/setup.py index 9ca8a9a..11f1651 100644 --- a/setup.py +++ b/setup.py @@ -27,8 +27,5 @@ setup( [paste.paster_command] loadanalytics = ckanext.googleanalytics.commands:LoadAnalytics initdb = ckanext.googleanalytics.commands:InitDB - [console_scripts] - ckanext-googleanalytics = ckanext.googleanalytics.cli:googleanalytics - """, )