Skip to content

Commit

Permalink
Merge branch 'master' of github.com:okfn/ckan
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed Jul 23, 2013
2 parents 854015a + 8e8e3dc commit a7a2714
Show file tree
Hide file tree
Showing 166 changed files with 37,242 additions and 26,356 deletions.
2 changes: 1 addition & 1 deletion .tx/config
@@ -1,5 +1,5 @@
[main]
host = http://www.transifex.net
host = https://www.transifex.com

[ckan.2-0]
file_filter = ckan/i18n/<lang>/LC_MESSAGES/ckan.po
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -7,6 +7,15 @@
Changelog
---------

v2.2
====

API changes and deprecations:

* The edit() and after_update() methods of IPackageController plugins are now
called when updating a resource using the web frontend or the
resource_update API action [#1052]

v2.0.1 2013-06-11
=================

Expand Down
7 changes: 3 additions & 4 deletions CONTRIBUTING.rst
Expand Up @@ -161,11 +161,10 @@ This section will walk you through the steps for making a pull request.
its own branch forked from the master branch.

The name of the branch should include the issue number (if this work has an
issue in the `CKAN issue tracker`_), the branch type (e.g. "feature" or
"bug"), and a brief one-line synopsis of the work, for example::
issue in the `CKAN issue tracker`_), and a brief one-line synopsis of the work,
for example::

2298-feature-add-sort-by-controls-to-search-page
1518-bug-upload-file-with-spaces
2298-add-sort-by-controls-to-search-page


#. Fork CKAN on GitHub
Expand Down
4 changes: 2 additions & 2 deletions bin/ckan_spam.py
Expand Up @@ -14,7 +14,7 @@

import os

from sqlobject import *
import sqlobject

import loadconfig
path = os.path.abspath(cfg_path)
Expand All @@ -36,7 +36,7 @@ def purge_packages_by_name():
pkg = model.Package.byName(pkg_name)
# for efficiency reasons best to have revisions in descending order
sel = model.PackageRevision.select(
AND(model.PackageRevision.q.baseID==pkg.id,
sqlobject.AND(model.PackageRevision.q.baseID==pkg.id,
model.PackageRevision.q.revisionID>=start_at_id),
orderBy=-model.PackageRevision.q.revisionID,
)
Expand Down
23 changes: 22 additions & 1 deletion bin/travis-build
Expand Up @@ -27,6 +27,9 @@ pip install -r requirements.txt -r dev-requirements.txt --use-mirrors

python setup.py develop

# Install npm dpes for mocha
npm install -g mocha-phantomjs phantomjs

# Configure Solr
echo "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
# FIXME the solr schema cannot be hardcoded as it is dependent on the ckan version
Expand All @@ -47,5 +50,23 @@ fi

cat test-core.ini

# And finally, run the tests
# Run mocha front-end tests
# We need ckan to be running for some tests
paster serve test-core.ini &
sleep 5 # Make sure the server has fully started
mocha-phantomjs http://localhost:5000/base/test/index.html
# Did an error occur?
MOCHA_ERROR=$?
# We are done so kill ckan
killall paster

# And finally, run the nosetests
nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext
# Did an error occur?
NOSE_ERROR=$?

[ "0" -ne "$MOCHA_ERROR" ] && echo MOCKA tests have failed
[ "0" -ne "$NOSE_ERROR" ] && echo NOSE tests have failed

# If an error occured in our tests make sure travis knows
exit `expr $MOCHA_ERROR + $NOSE_ERROR`
74 changes: 0 additions & 74 deletions build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion ckan/__init__.py
@@ -1,4 +1,4 @@
__version__ = '2.1a'
__version__ = '2.2a'

__description__ = 'Comprehensive Knowledge Archive Network (CKAN) Software'
__long_description__ = \
Expand Down
13 changes: 11 additions & 2 deletions ckan/config/routing.py
Expand Up @@ -279,7 +279,6 @@ def make_map():
requirements=dict(action='|'.join([
'edit',
'delete',
'members',
'member_new',
'member_delete',
'history',
Expand All @@ -291,6 +290,10 @@ def make_map():
])))
m.connect('group_about', '/group/about/{id}', action='about',
ckan_icon='info-sign'),
m.connect('group_edit', '/group/edit/{id}', action='edit',
ckan_icon='edit')
m.connect('group_members', '/group/members/{id}', action='members',
ckan_icon='group'),
m.connect('group_activity', '/group/activity/{id}/{offset}',
action='activity', ckan_icon='time'),
m.connect('group_read', '/group/{id}', action='read',
Expand Down Expand Up @@ -343,9 +346,15 @@ def make_map():
m.connect('/user/activity/{id}/{offset}', action='activity')
m.connect('user_activity_stream', '/user/activity/{id}',
action='activity', ckan_icon='time')
m.connect('/dashboard/{offset}', action='dashboard')
m.connect('user_dashboard', '/dashboard', action='dashboard',
ckan_icon='list')
m.connect('user_dashboard_datasets', '/dashboard/datasets',
action='dashboard_datasets', ckan_icon='sitemap')
m.connect('user_dashboard_groups', '/dashboard/groups',
action='dashboard_groups', ckan_icon='group')
m.connect('user_dashboard_organizations', '/dashboard/organizations',
action='dashboard_organizations', ckan_icon='building')
m.connect('/dashboard/{offset}', action='dashboard')
m.connect('user_follow', '/user/follow/{id}', action='follow')
m.connect('/user/unfollow/{id}', action='unfollow')
m.connect('user_followers', '/user/followers/{id:.*}',
Expand Down
8 changes: 4 additions & 4 deletions ckan/controllers/admin.py
Expand Up @@ -32,10 +32,10 @@ def _get_config_form_items(self):
{'text': 'Maroon', 'value': '/base/css/maroon.css'},
{'text': 'Fuchsia', 'value': '/base/css/fuchsia.css'}]
items = [
{'name': 'ckan.site_title', 'control': 'input', 'label': _('Site Title'), 'placeholder': _('')},
{'name': 'ckan.main_css', 'control': 'select', 'options': styles, 'label': _('Style'), 'placeholder': _('')},
{'name': 'ckan.site_description', 'control': 'input', 'label': _('Site Tag Line'), 'placeholder': _('')},
{'name': 'ckan.site_logo', 'control': 'input', 'label': _('Site Tag Logo'), 'placeholder': _('')},
{'name': 'ckan.site_title', 'control': 'input', 'label': _('Site Title'), 'placeholder': ''},
{'name': 'ckan.main_css', 'control': 'select', 'options': styles, 'label': _('Style'), 'placeholder': ''},
{'name': 'ckan.site_description', 'control': 'input', 'label': _('Site Tag Line'), 'placeholder': ''},
{'name': 'ckan.site_logo', 'control': 'input', 'label': _('Site Tag Logo'), 'placeholder': ''},
{'name': 'ckan.site_about', 'control': 'markdown', 'label': _('About'), 'placeholder': _('About page text')},
{'name': 'ckan.site_intro_text', 'control': 'markdown', 'label': _('Intro Text'), 'placeholder': _('Text on home page')},
{'name': 'ckan.site_custom_css', 'control': 'textarea', 'label': _('Custom CSS'), 'placeholder': _('Customisable css inserted into the page header')},
Expand Down
2 changes: 1 addition & 1 deletion ckan/controllers/group.py
Expand Up @@ -281,7 +281,7 @@ def pager_url(q=None, page=None):
default_facet_titles = {'groups': _('Groups'),
'tags': _('Tags'),
'res_format': _('Formats'),
'license': _('License')}
'license_id': _('License')}

for facet in g.facets:
if facet in default_facet_titles:
Expand Down
4 changes: 2 additions & 2 deletions ckan/controllers/organization.py
Expand Up @@ -19,7 +19,7 @@ def _group_form(self, group_type=None):
return 'organization/new_organization_form.html'

def _form_to_db_schema(self, group_type=None):
return lookup_group_plugin(group_type).form_to_db_schema()
return group.lookup_group_plugin(group_type).form_to_db_schema()

def _db_to_form_schema(self, group_type=None):
'''This is an interface to manipulate data from the database
Expand Down Expand Up @@ -48,7 +48,7 @@ def _read_template(self, group_type):
return 'organization/read.html'

def _history_template(self, group_type):
return lookup_group_plugin(group_type).history_template()
return group.lookup_group_plugin(group_type).history_template()

def _edit_template(self, group_type):
return 'organization/edit.html'
Expand Down
45 changes: 23 additions & 22 deletions ckan/controllers/package.py
Expand Up @@ -344,6 +344,11 @@ def read(self, id, format='html'):
c.current_package_id = c.pkg.id
c.related_count = c.pkg.related_count

# can the resources be previewed?
for resource in c.pkg_dict['resources']:
resource['can_be_previewed'] = self._resource_preview(
{'resource': resource, 'package': c.pkg_dict})

self._setup_template_variables(context, {'id': id},
package_type=package_type)

Expand Down Expand Up @@ -1142,8 +1147,17 @@ def resource_read(self, id, resource_id):
c.datastore_api = '%s/api/action' % config.get('ckan.site_url', '').rstrip('/')

c.related_count = c.pkg.related_count

c.resource['can_be_previewed'] = self._resource_preview(
{'resource': c.resource, 'package': c.package})
return render('package/resource_read.html')

def _resource_preview(self, data_dict):
return bool(datapreview.res_format(data_dict['resource'])
in datapreview.direct() + datapreview.loadable()
or datapreview.get_preview_plugin(
data_dict, return_first=True))

def resource_download(self, id, resource_id):
"""
Provides a direct download by redirecting the user to the url stored
Expand Down Expand Up @@ -1319,9 +1333,9 @@ def resource_datapreview(self, id, resource_id):
'''
Embeded page for a resource data-preview.
Depending on the type, different previews are loaded.
This could be an img tag where the image is loaded directly or an iframe that
embeds a webpage, recline or a pdf preview.
Depending on the type, different previews are loaded. This could be an
img tag where the image is loaded directly or an iframe that embeds a
webpage, recline or a pdf preview.
'''
context = {
'model': model,
Expand All @@ -1335,30 +1349,17 @@ def resource_datapreview(self, id, resource_id):
c.package = get_action('package_show')(context, {'id': id})

data_dict = {'resource': c.resource, 'package': c.package}
on_same_domain = datapreview.resource_is_on_same_domain(data_dict)
data_dict['resource']['on_same_domain'] = on_same_domain

# FIXME this wants to not use plugins as it is an imported name
# and we already import it an p should really only be in
# extensu=ions in my opinion also just make it look nice and be
# readable grrrrrr
plugins = p.PluginImplementations(p.IResourcePreview)
plugins_that_can_preview = [plugin for plugin in plugins
if plugin.can_preview(data_dict)]
if len(plugins_that_can_preview) == 0:
abort(409, _('No preview has been defined.'))
if len(plugins_that_can_preview) > 1:
log.warn('Multiple previews are possible. {0}'.format(
plugins_that_can_preview))

plugin = plugins_that_can_preview[0]
plugin.setup_template_variables(context, data_dict)
preview_plugin = datapreview.get_preview_plugin(data_dict)

c.resource_json = json.dumps(c.resource)
if preview_plugin is None:
abort(409, _('No preview has been defined.'))

preview_plugin.setup_template_variables(context, data_dict)
c.resource_json = json.dumps(c.resource)
except NotFound:
abort(404, _('Resource not found'))
except NotAuthorized:
abort(401, _('Unauthorized to read resource %s') % id)
else:
return render(plugin.preview_template(context, data_dict))
return render(preview_plugin.preview_template(context, data_dict))

0 comments on commit a7a2714

Please sign in to comment.