Skip to content

Commit

Permalink
[399] merge issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed Jul 22, 2013
2 parents 42ef41f + 79241c4 commit 14b50de
Show file tree
Hide file tree
Showing 189 changed files with 36,470 additions and 25,828 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
11 changes: 10 additions & 1 deletion 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 Expand Up @@ -423,7 +432,7 @@ v1.5 2011-11-07
Major:
* New visual theme (#1108)
* Package & Resource edit overhaul (#1294/#1348/#1351/#1368/#1296)
* JS and CSS reorganisation (#1282, #1349, #1380)
* JS and CSS reorganization (#1282, #1349, #1380)
* Apache Solr used for search in core instead of Postgres (#1275, #1361, #1365)
* Authorization system now embedded in the logic layer (#1253)
* Captcha added for user registration (#1307, #1431)
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
1 change: 1 addition & 0 deletions bin/ckan_edit_local.py
Expand Up @@ -84,6 +84,7 @@ def canada_extras():
'Level of Government':'level_of_government',
}
license_mapping = {
# CS: bad_spelling ignore
'http://geogratis.ca/geogratis/en/licence.jsp':'geogratis',
'Crown Copyright':'canada-crown',
}
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
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
2 changes: 1 addition & 1 deletion ckan/config/deployment.ini_tmpl
Expand Up @@ -107,7 +107,7 @@ ckan.preview.loadable = html htm rdf+xml owl+xml xml n3 n-triples turtle plain a
ckan.locale_default = en
ckan.locale_order = en pt_BR ja it cs_CZ ca es fr el sv sr sr@latin no sk fi ru de pl nl bg ko_KR hu sa sl lv
ckan.locales_offered =
ckan.locales_filtered_out =
ckan.locales_filtered_out = en_GB


## Feeds Settings
Expand Down
13 changes: 11 additions & 2 deletions ckan/config/routing.py
Expand Up @@ -277,7 +277,6 @@ def make_map():
requirements=dict(action='|'.join([
'edit',
'delete',
'members',
'member_new',
'member_delete',
'history',
Expand All @@ -289,6 +288,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 @@ -341,9 +344,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
14 changes: 9 additions & 5 deletions ckan/controllers/api.py
Expand Up @@ -158,7 +158,7 @@ def action(self, logic_function, ver=None):
except KeyError:
log.error('Can\'t find logic function: %s' % logic_function)
return self._finish_bad_request(
_('Action name not known: %s') % str(logic_function))
_('Action name not known: %s') % logic_function)

context = {'model': model, 'session': model.Session, 'user': c.user,
'api_version': ver}
Expand All @@ -169,9 +169,9 @@ def action(self, logic_function, ver=None):
request_data = self._get_request_data(try_url_params=
side_effect_free)
except ValueError, inst:
log.error('Bad request data: %s' % str(inst))
log.error('Bad request data: %s' % inst)
return self._finish_bad_request(
_('JSON Error: %s') % str(inst))
_('JSON Error: %s') % inst)
if not isinstance(request_data, dict):
# this occurs if request_data is blank
log.error('Bad request data - not dict: %r' % request_data)
Expand Down Expand Up @@ -210,6 +210,7 @@ def action(self, logic_function, ver=None):
error_dict['__type'] = 'Validation Error'
return_dict['error'] = error_dict
return_dict['success'] = False
# CS nasty_string ignore
log.error('Validation error: %r' % str(e.error_dict))
return self._finish(409, return_dict, content_type='json')
except search.SearchQueryError, e:
Expand Down Expand Up @@ -334,7 +335,7 @@ def create(self, ver=None, register=None, subregister=None,
data_dict.update(request_data)
except ValueError, inst:
return self._finish_bad_request(
_('JSON Error: %s') % str(inst))
_('JSON Error: %s') % inst)

action = self._get_action_from_map(action_map, register, subregister)
if not action:
Expand All @@ -357,6 +358,7 @@ def create(self, ver=None, register=None, subregister=None,
extra_msg = e.extra_msg
return self._finish_not_found(extra_msg)
except ValidationError, e:
# CS: nasty_string ignore
log.error('Validation error: %r' % str(e.error_dict))
return self._finish(409, e.error_dict, content_type='json')
except DataError, e:
Expand Down Expand Up @@ -396,7 +398,7 @@ def update(self, ver=None, register=None, subregister=None,
data_dict.update(request_data)
except ValueError, inst:
return self._finish_bad_request(
_('JSON Error: %s') % str(inst))
_('JSON Error: %s') % inst)

action = self._get_action_from_map(action_map, register, subregister)
if not action:
Expand All @@ -412,6 +414,7 @@ def update(self, ver=None, register=None, subregister=None,
extra_msg = e.extra_msg
return self._finish_not_found(extra_msg)
except ValidationError, e:
# CS: nasty_string ignore
log.error('Validation error: %r' % str(e.error_dict))
return self._finish(409, e.error_dict, content_type='json')
except DataError, e:
Expand Down Expand Up @@ -459,6 +462,7 @@ def delete(self, ver=None, register=None, subregister=None,
extra_msg = e.extra_msg
return self._finish_not_found(extra_msg)
except ValidationError, e:
# CS: nasty_string ignore
log.error('Validation error: %r' % str(e.error_dict))
return self._finish(409, e.error_dict, content_type='json')

Expand Down
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -524,7 +524,7 @@ def _save_edit(self, id, context):
if id != group['name']:
self._force_reindex(group)

h.redirect_to('%s_read' % str(group['type']), id=group['name'])
h.redirect_to('%s_read' % group['type'], id=group['name'])
except NotAuthorized:
abort(401, _('Unauthorized to read group %s') % id)
except NotFound, e:
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 14b50de

Please sign in to comment.