This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from datagovuk/move-model-setup-to-command
Move model setup to a command
- Loading branch information
Showing
4 changed files
with
146 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from ckan.lib.cli import CkanCommand | ||
|
||
import logging | ||
import sys | ||
|
||
from pylons import config | ||
|
||
class Issues(CkanCommand): | ||
""" | ||
Usage: | ||
paster issues init_db | ||
- Creates the database table issues needs to run | ||
""" | ||
summary = __doc__.split('\n')[0] | ||
usage = __doc__ | ||
|
||
def command(self): | ||
""" | ||
Parse command line arguments and call appropriate method. | ||
""" | ||
if not self.args or self.args[0] in ['--help', '-h', 'help']: | ||
print self.usage | ||
sys.exit(1) | ||
|
||
cmd = self.args[0] | ||
self._load_config() | ||
|
||
self.log = logging.getLogger(__name__) | ||
|
||
if cmd == 'init_db': | ||
from ckanext.issues.model import setup | ||
setup() | ||
self.log.info('Issues tables are initialized') | ||
else: | ||
self.log.error('Command %s not recognized' % (cmd,)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters