Skip to content

Commit

Permalink
Merge pull request #3024 from CarlQLange/patch-2
Browse files Browse the repository at this point in the history
Add a submit_all command to datapusher.
  • Loading branch information
wardi committed Jun 23, 2016
2 parents dfd0af9 + dfd2a91 commit a10edd3
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions ckanext/datapusher/cli.py
Expand Up @@ -16,6 +16,9 @@ class DatapusherCommand(cli.CkanCommand):
ignoring if their files haven't changed.
submit <pkgname> - Submits all resources from the package
identified by pkgname (either the short name or ID).
submit_all - Submit every package to the datastore.
This is useful if you're setting up datastore
for a ckan that already has datasets.
'''

summary = __doc__.split('\n')[0]
Expand All @@ -26,7 +29,12 @@ def command(self):
self._confirm_or_abort()

self._load_config()
self._submit_all()
self._resubmit_all()
elif self.args and self.args[0] == 'submit_all':
self._confirm_or_abort()

self._load_config()
self._submit_all_packages()
elif self.args and self.args[0] == 'submit':
self._confirm_or_abort()

Expand All @@ -51,10 +59,19 @@ def _confirm_or_abort(self):
print "Aborting..."
sys.exit(0)

def _submit_all(self):
def _resubmit_all(self):
resources_ids = datastore_db.get_all_resources_ids_in_datastore()
self._submit(resource_ids)

def _submit_all_packages(self):
# submit every package
# for each package in the package list,
# submit each resource w/ _submit_package
import ckan.model as model
package_list = p.toolkit.get_action('package_list')
for p_id in package_list({'model': model, 'ignore_auth': True}, {}):
self._submit_package(p_id)

def _submit_package(self, pkg_id):
import ckan.model as model

Expand Down

0 comments on commit a10edd3

Please sign in to comment.