Skip to content

Commit

Permalink
Merge branch 'master' into 368-new-history-page-2
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/templates/package/read_base.html
  • Loading branch information
domoritz committed Mar 26, 2013
2 parents adfc4bf + 8c8680d commit 7791070
Show file tree
Hide file tree
Showing 210 changed files with 3,182 additions and 6,658 deletions.
28 changes: 4 additions & 24 deletions .travis.yml
Expand Up @@ -2,30 +2,10 @@ language: python
python:
- "2.6"
- "2.7"
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq solr-jetty
install:
- "pip install -r pip-requirements.txt --use-mirrors"
- "pip install -r pip-requirements-test.txt --use-mirrors"
before_script:
- psql -c 'CREATE DATABASE ckantest;' -U postgres
- psql -c 'CREATE DATABASE datastore;' -U postgres
- psql -c 'CREATE USER readonlyuser;' -U postgres
- python setup.py develop
- paster make-config ckan development.ini --no-interactive
- sed -i -e 's/.*solr_url.*/solr_url = http:\/\/127.0.0.1:8983\/solr/' development.ini
- sed -i -e 's/.*ckan\.site_id.*/ckan.site_id = travis_ci/' development.ini
- sed -i -e 's/^sqlalchemy.url.*/sqlalchemy.url = postgresql:\/\/postgres@localhost\/ckantest/' development.ini
- sed -i -e 's/.*datastore.write_url.*/ckan.datastore.write_url = postgresql:\/\/postgres@localhost\/datastore/' development.ini
- sed -i -e 's/.*datastore.read_url.*/ckan.datastore.read_url = postgresql:\/\/readonlyuser@localhost\/datastore/' development.ini
- cat development.ini
- echo -e "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
- sudo cp ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml
- sudo service jetty restart
- paster --plugin=ckan db init
- paster datastore set-permissions postgres
script: "nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext"
env:
- PGVERSION=9.1
- PGVERSION=8.4
script: ./bin/travis-build
notifications:
irc:
channels:
Expand Down
55 changes: 55 additions & 0 deletions bin/travis-build
@@ -0,0 +1,55 @@
#!/bin/sh

# Drop Travis' postgres cluster if we're building using a different pg version
TRAVIS_PGVERSION='9.1'
if [ $PGVERSION != $TRAVIS_PGVERSION ]
then
sudo -u postgres pg_dropcluster --stop $TRAVIS_PGVERSION main
# Make psql use $PGVERSION
export PGCLUSTER=$PGVERSION/main
fi

# Install postgres and solr
# We need this ppa so we can install postgres-8.4
sudo add-apt-repository -yy ppa:pitti/postgresql
sudo apt-get update -qq
sudo apt-get install solr-jetty postgresql-$PGVERSION

# Don't require a password to access DB
sudo sed -i -e 's/ident/trust/g' /etc/postgresql/$PGVERSION/main/pg_hba.conf

sudo service postgresql reload

pip install -r pip-requirements.txt --use-mirrors
pip install -r pip-requirements-test.txt --use-mirrors

psql -c 'CREATE DATABASE ckantest;' -U postgres
psql -c 'CREATE DATABASE datastore;' -U postgres

python setup.py develop

# Configure CKAN's configuration file
paster make-config ckan development.ini --no-interactive
sed -i -e 's/.*solr_url.*/solr_url = http:\/\/127.0.0.1:8983\/solr/' development.ini
sed -i -e 's/.*ckan\.site_id.*/ckan.site_id = travis_ci/' development.ini
sed -i -e 's/^sqlalchemy.url.*/sqlalchemy.url = postgresql:\/\/postgres@\/ckantest/' development.ini
sed -i -e 's/.*datastore.write_url.*/ckan.datastore.write_url = postgresql:\/\/postgres@\/datastore/' development.ini

# Configure Solr
echo "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
sudo cp ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml
sudo service jetty restart

paster --plugin=ckan db init

# If Postgres >= 9.0, we don't need to use datastore's legacy mode.
if [ $PGVERSION != '8.4' ]
then
psql -c 'CREATE USER readonlyuser;' -U postgres
sed -i -e 's/.*datastore.read_url.*/ckan.datastore.read_url = postgresql:\/\/readonlyuser@\/datastore/' development.ini
paster datastore set-permissions postgres
fi


# And finally, run the tests
nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext
17 changes: 17 additions & 0 deletions ckan/common.py
@@ -0,0 +1,17 @@
# This file contains commonly used parts of external libraries. The idea is
# to help in removing helpers from being used as a dependency by many files
# but at the same time making it easy to change for example the json lib
# used.
#
# NOTE: This file is specificaly created for
# from ckan.common import x, y, z to be allowed


from pylons.i18n import _, ungettext
from pylons import g, c, request, session, response
import simplejson as json

try:
from collections import OrderedDict # from python 2.7
except ImportError:
from sqlalchemy.util import OrderedDict
27 changes: 19 additions & 8 deletions ckan/config/routing.py
Expand Up @@ -284,12 +284,15 @@ def make_map():
'follow',
'unfollow',
'admins',
'about',
'activity',
]))
)
m.connect('group_activity', '/group/activity/{id}/{offset}', action='activity'),
m.connect('group_read', '/group/{id}', action='read')
m.connect('group_about', '/group/about/{id}', action='about',
ckan_icon='info-sign'),
m.connect('group_activity', '/group/activity/{id}/{offset}',
action='activity', ckan_icon='time'),
m.connect('group_read', '/group/{id}', action='read',
ckan_icon='sitemap')

# organizations these basically end up being the same as groups
with SubMapper(map, controller='organization') as m:
Expand All @@ -298,18 +301,26 @@ def make_map():
m.connect('/organization/new', action='new')
m.connect('/organization/{action}/{id}',
requirements=dict(action='|'.join([
'edit',
'delete',
'admins',
'members',
'member_new',
'member_delete',
'history',
'bulk_process',
'about'
'history'
]))
)
m.connect('organization_activity', '/organization/activity/{id}',
action='activity', ckan_icon='time')
m.connect('organization_read', '/organization/{id}', action='read')
m.connect('organization_about', '/organization/about/{id}',
action='about', ckan_icon='info-sign')
m.connect('organization_read', '/organization/{id}', action='read',
ckan_icon='sitemap')
m.connect('organization_edit', '/organization/edit/{id}',
action='edit', ckan_icon='edit')
m.connect('organization_members', '/organization/members/{id}',
action='members', ckan_icon='group')
m.connect('organization_bulk_process', '/organization/bulk_process/{id}',
action='bulk_process', ckan_icon='sitemap')
register_package_plugins(map)
register_group_plugins(map)

Expand Down
12 changes: 6 additions & 6 deletions ckan/controllers/feed.py
Expand Up @@ -29,7 +29,7 @@

from ckan import model
from ckan.lib.base import BaseController, c, request, response, json, abort, g
from ckan.lib.helpers import date_str_to_datetime, url_for
import ckan.lib.helpers as h
from ckan.logic import get_action, NotFound

# TODO make the item list configurable
Expand Down Expand Up @@ -348,18 +348,18 @@ def output_feed(self, results, feed_title, feed_description,
for pkg in results:
feed.add_item(
title=pkg.get('title', ''),
link=self.base_url + url_for(controller='package',
link=self.base_url + h.url_for(controller='package',
action='read',
id=pkg['id']),
description=pkg.get('notes', ''),
updated=date_str_to_datetime(pkg.get('metadata_modified')),
published=date_str_to_datetime(pkg.get('metadata_created')),
updated=h.date_str_to_datetime(pkg.get('metadata_modified')),
published=h.date_str_to_datetime(pkg.get('metadata_created')),
unique_id=_create_atom_id(u'/dataset/%s' % pkg['id']),
author_name=pkg.get('author', ''),
author_email=pkg.get('author_email', ''),
categories=[t['name'] for t in pkg.get('tags', [])],
enclosure=webhelpers.feedgenerator.Enclosure(
self.base_url + url_for(controller='api',
self.base_url + h.url_for(controller='api',
register='package',
action='show',
id=pkg['name'],
Expand All @@ -377,7 +377,7 @@ def _feed_url(self, query, controller, action, **kwargs):
Constructs the url for the given action. Encoding the query
parameters.
"""
path = url_for(controller=controller, action=action, **kwargs)
path = h.url_for(controller=controller, action=action, **kwargs)
query = [(k, v.encode('utf-8') if isinstance(v, basestring)
else str(v)) for k, v in query.items()]

Expand Down

0 comments on commit 7791070

Please sign in to comment.