-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
301 additions
and
225 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,11 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
# command to install dependencies | ||
install: | ||
- "pip install -e ." | ||
- "pip install -r requirements.txt" | ||
- "pip install -r dev_requirements.txt" | ||
# command to run tests | ||
script: coverage run --source=ckanext-gallery setup.py nosetests | ||
after_success: coveralls |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
# this is a namespace package | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
# | ||
# This file is part of ckanext-gallery | ||
# Created by the Natural History Museum in London, UK | ||
|
||
try: | ||
import pkg_resources | ||
pkg_resources.declare_namespace(__name__) | ||
except ImportError: | ||
import pkgutil | ||
__path__ = pkgutil.extend_path(__path__, __name__) | ||
__path__ = pkgutil.extend_path(__path__, __name__) |
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 |
---|---|---|
@@ -1,18 +1,13 @@ | ||
#!/usr/bin/env python | ||
# !/usr/bin/env python | ||
# encoding: utf-8 | ||
""" | ||
Created by 'bens3' on 2013-06-21. | ||
Copyright (c) 2013 'bens3'. All rights reserved. | ||
""" | ||
|
||
import sys | ||
import os | ||
# | ||
# This file is part of ckanext-gallery | ||
# Created by the Natural History Museum in London, UK | ||
|
||
|
||
def main(): | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
if __name__ == u'__main__': | ||
main() | ||
|
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 |
---|---|---|
@@ -1,24 +1,28 @@ | ||
#!/usr/bin/env python | ||
# !/usr/bin/env python | ||
# encoding: utf-8 | ||
""" | ||
Created by 'bens3' on 2013-06-21. | ||
Copyright (c) 2013 'bens3'. All rights reserved. | ||
""" | ||
# | ||
# This file is part of ckanext-gallery | ||
# Created by the Natural History Museum in London, UK | ||
|
||
import ckan.plugins as p | ||
from ckan.plugins import toolkit | ||
|
||
_cache = {} | ||
|
||
|
||
def get_datastore_fields(resource_id): | ||
""" | ||
Retrieve list of dataset fields | ||
'''Retrieve list of dataset fields | ||
Checked between requests so we can quickly reuse without searching again | ||
:param resource_id: | ||
:return: | ||
""" | ||
:param resource_id: return: | ||
''' | ||
try: | ||
fields = _cache[resource_id] | ||
except KeyError: | ||
data = {'resource_id': resource_id, 'limit': 0} | ||
fields = _cache[resource_id] = p.toolkit.get_action('datastore_search')({}, data)['fields'] | ||
return fields | ||
data = { | ||
u'resource_id': resource_id, | ||
u'limit': 0 | ||
} | ||
fields = _cache[resource_id] = \ | ||
toolkit.get_action(u'datastore_search')({}, data)[u'fields'] | ||
return fields |
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 |
---|---|---|
@@ -1,28 +1,23 @@ | ||
#!/usr/bin/env python | ||
# !/usr/bin/env python | ||
# encoding: utf-8 | ||
""" | ||
Created by 'bens3' on 2013-06-21. | ||
Copyright (c) 2013 'bens3'. All rights reserved. | ||
""" | ||
|
||
import ckan.plugins as p | ||
from ckan.common import _ | ||
# | ||
# This file is part of ckanext-gallery | ||
# Created by the Natural History Museum in London, UK | ||
|
||
from ckanext.gallery.lib.helpers import get_datastore_fields | ||
|
||
Invalid = p.toolkit.Invalid | ||
from ckan.plugins import toolkit | ||
|
||
|
||
def is_datastore_field(value, context): | ||
''' | ||
Make sure this field is an actual datastore field | ||
'''Make sure this field is an actual datastore field | ||
:param value: | ||
:param context: | ||
:raises: ckan.lib.navl.dictization_functions.Invalid for other | ||
inputs or non-whole values | ||
''' | ||
fields = get_datastore_fields(context['resource'].id) | ||
fields = get_datastore_fields(toolkit.c.resource.get(u'id')) | ||
for field in fields: | ||
if field['id'] in value: | ||
if field[u'id'] in value: | ||
return value | ||
raise Invalid(_('Field {0} not in datastore'.format(value))) | ||
|
||
raise toolkit.Invalid(toolkit._(u'Field {0} not in datastore'.format(value))) |
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 |
---|---|---|
@@ -1,18 +1,13 @@ | ||
#!/usr/bin/env python | ||
# !/usr/bin/env python | ||
# encoding: utf-8 | ||
""" | ||
Created by 'bens3' on 2013-06-21. | ||
Copyright (c) 2013 'bens3'. All rights reserved. | ||
""" | ||
|
||
import sys | ||
import os | ||
# | ||
# This file is part of ckanext-gallery | ||
# Created by the Natural History Museum in London, UK | ||
|
||
|
||
def main(): | ||
pass | ||
|
||
|
||
if __name__ == '__main__': | ||
if __name__ == u'__main__': | ||
main() | ||
|
Oops, something went wrong.