Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Move init logic in command #38

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ To install ckanext-showcase:

pip install ckanext-showcase

3. Add ``showcase`` to the ``ckan.plugins`` setting in your CKAN
3. Run the ``init`` command to initialize the plugin and make all necessary changes to the database::

paster --plugin=ckanext-showcase showcase init -c {path to production.ini}

4. Add ``showcase`` to the ``ckan.plugins`` setting in your CKAN
config file (by default the config file is located at
``/etc/ckan/default/production.ini``).

4. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu::
5. Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu::

sudo service apache2 reload

Expand Down
1 change: 1 addition & 0 deletions bin/travis-build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cd -

echo "Installing ckanext-showcase and its requirements..."
python setup.py develop
paster showcase init -c ckan/test-core.ini
pip install -r dev-requirements.txt

echo "Moving test.ini into a subdir..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
from ckan.lib.munge import munge_title_to_name, substitute_ascii_equivalents
from ckan.logic import get_action

from ckanext.showcase.model import setup as model_setup


import logging
log = logging.getLogger(__name__)


class MigrationCommand(CkanCommand):
class ShowcaseCommand(CkanCommand):
'''
CKAN 'Related Items' to 'Showcase' migration command.
Commands for showcase extension

Usage::

paster showcase init -c <path to config file>
- Initialize the extension, create tables

paster showcase migrate -c <path to config file>
- Migrate Related Items to Showcases

Expand All @@ -35,11 +40,15 @@ def command(self):

if cmd == 'migrate':
self.migrate()
elif cmd == 'make_related':
self.make_related()
elif cmd == 'init':
self.init()
else:
print('Command "{0}" not recognized'.format(cmd))

def init(self):
print "Setup all tables"
model_setup()

def migrate(self):
'''

Expand Down
7 changes: 0 additions & 7 deletions ckanext/showcase/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import ckanext.showcase.logic.action.get
import ckanext.showcase.logic.schema as showcase_schema
import ckanext.showcase.logic.helpers as showcase_helpers
from ckanext.showcase.model import setup as model_setup

c = tk.c
_ = tk._
Expand All @@ -29,7 +28,6 @@


class ShowcasePlugin(plugins.SingletonPlugin, lib_plugins.DefaultDatasetForm):
plugins.implements(plugins.IConfigurable)
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.IDatasetForm)
plugins.implements(plugins.IFacets, inherit=True)
Expand All @@ -54,11 +52,6 @@ def update_config(self, config):
tk.add_ckan_admin_tab(config, 'ckanext_showcase_admins',
'Showcase Config')

# IConfigurable

def configure(self, config):
model_setup()

# IDatasetForm

def package_types(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
ckan = ckan.lib.extract:extract_ckan

[paste.paster_command]
showcase=ckanext.showcase.commands.migrate:MigrationCommand
showcase=ckanext.showcase.commands.showcase:ShowcaseCommand
''',

message_extractors={
Expand Down