-
Notifications
You must be signed in to change notification settings - Fork 39
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 #68 from NaturalHistoryMuseum/josh/ckan-upgrade-2.9
CKAN 2.9.x upgrade
- Loading branch information
Showing
26 changed files
with
643 additions
and
578 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,2 @@ | ||
[run] | ||
relative_files = True |
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 |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
*.pyc | ||
.noseids | ||
|
||
\.coverage | ||
|
||
.coverage | ||
.idea |
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,19 +1,16 @@ | ||
dist: trusty | ||
language: python | ||
|
||
python: | ||
- "2.7" | ||
sudo: required | ||
|
||
install: | ||
- sh ckanext/ldap/tests/bin/build.sh | ||
language: python | ||
|
||
services: | ||
- redis-server | ||
- postgresql | ||
- docker | ||
|
||
addons: | ||
postgresql: "9.4" | ||
# we need coveralls and this also prevents travis from running pip install -r requirements.txt | ||
install: pip install coveralls | ||
|
||
script: coverage run --source=ckanext.ldap setup.py nosetests --ckan --with-pylons=ckanext/ldap/tests/bin/test.ini --nologcapture --debug=ckantest,ckanext.ldap --rednose | ||
script: | ||
- docker-compose build | ||
- docker-compose run ckan | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import click | ||
|
||
from ckan.plugins import toolkit | ||
from ckanext.ldap.model.ldap_user import ldap_user_table | ||
|
||
|
||
def get_commands(): | ||
return [ldap] | ||
|
||
|
||
@click.group() | ||
def ldap(): | ||
''' | ||
The LDAP CLI. | ||
''' | ||
pass | ||
|
||
|
||
@ldap.command(name='initdb') | ||
def init_db(): | ||
''' | ||
Ensures the database tables we need exist in the database and creates them if they don't. | ||
''' | ||
if not ldap_user_table.exists(): | ||
ldap_user_table.create() | ||
click.secho(f'Created {ldap_user_table.name} table', fg='green') | ||
else: | ||
click.secho(f'Table {ldap_user_table.name} already exists', fg='green') | ||
|
||
|
||
@ldap.command(name='setup-org') | ||
def setup_org(): | ||
''' | ||
Sets up the default organisation which all ldap users will be automatically made members of. | ||
''' | ||
# get the organisation all users will be added to | ||
organization_id = toolkit.config['ckanext.ldap.organization.id'] | ||
|
||
# set up context | ||
user = toolkit.get_action('get_site_user')({ | ||
'ignore_auth': True | ||
}, {}) | ||
context = { | ||
'user': user['name'] | ||
} | ||
|
||
try: | ||
toolkit.get_action('organization_show')(context, { | ||
'id': organization_id | ||
}) | ||
click.secho(u"Organisation already exists, doing nothing", fg=u"green") | ||
except toolkit.ObjectNotFound: | ||
# see the following commit to understand why this line is here | ||
# http://github.com/ckan/ckanext-harvest/commit/f315f41c86cbde4a49ef869b6993598f8cb11e2d | ||
context.pop('__auth_audit', None) | ||
toolkit.get_action('organization_create')(context, { | ||
'id': organization_id, | ||
'name': organization_id | ||
}) | ||
click.secho(u"New organisation created", fg=u"green") |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.