Skip to content

Commit

Permalink
Merge branch 'master' into feature-2579-sort-functions-to-helpers
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/lib/helpers.py

    trivial merge new code in branch none in master
  • Loading branch information
tobes committed Aug 20, 2012
2 parents 2c82a7c + 99a7aef commit 93bd7ad
Show file tree
Hide file tree
Showing 122 changed files with 62,343 additions and 24,370 deletions.
2 changes: 1 addition & 1 deletion .tx/config
@@ -1,7 +1,7 @@
[main]
host = http://www.transifex.net

[ckan.1-7]
[ckan.1-8]
file_filter = ckan/i18n/<lang>/LC_MESSAGES/ckan.po
source_file = ckan/i18n/ckan.pot
source_lang = en
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.txt
Expand Up @@ -30,6 +30,7 @@ v1.8
available by `setting ckan.restrict_template_vars = false` in your
.ini config file. Only restricted functions will be allowed in
future versions of CKAN.
* [#2842] Allow sort ordering of dataset listings on group pages

API changes and deprecation:
* [#2313] Deprecated functions related to the old faceting data structure have
Expand Down
2 changes: 1 addition & 1 deletion ckan/__init__.py
@@ -1,4 +1,4 @@
__version__ = '1.9a'
__version__ = '1.8b'
__description__ = 'Comprehensive Knowledge Archive Network (CKAN) Software'
__long_description__ = \
'''CKAN software provides a hub for datasets. The flagship site running CKAN
Expand Down
28 changes: 28 additions & 0 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -196,6 +196,34 @@ ckan.feeds.author_name =
# If not set, then the value in `ckan.site_url` is used.
ckan.feeds.author_link =

## File Store
#
# CKAN allows users to upload files directly to file storage either on the local
# file system or to online ‘cloud’ storage like Amazon S3 or Google Storage.
#
# If you are using local file storage, remember to set ckan.site_url.
#
# To enable cloud storage (Google or S3), first run: pip install boto
#
# @see http://docs.ckan.org/en/latest/filestore.html

# 'Bucket' to use for file storage
#ckan.storage.bucket = my-bucket-name

# To enable local file storage:
#ofs.impl = pairtree
#ofs.storage_dir = /my/path/to/storage/root/directory

# To enable Google cloud storage:
#ofs.impl = google
#ofs.gs_access_key_id =
#ofs.gs_secret_access_key =

# To enable S3 cloud storage:
#ofs.impl = s3
#ofs.aws_access_key_id = ....
#ofs.aws_secret_access_key = ....

## Webstore
## Uncommment to enable datastore
# ckan.datastore.enabled = 1
Expand Down
4 changes: 3 additions & 1 deletion ckan/config/environment.py
Expand Up @@ -16,7 +16,6 @@
import ckan.model as model
import ckan.plugins as p
import ckan.lib.helpers as h
import ckan.lib.search as search
import ckan.lib.app_globals as app_globals

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -161,6 +160,9 @@ def find_controller(self, controller):

# Init SOLR settings and check if the schema is compatible
#from ckan.lib.search import SolrSettings, check_solr_schema_version

# lib.search is imported here as we need the config enabled and parsed
import ckan.lib.search as search
search.SolrSettings.init(config.get('solr_url'),
config.get('solr_user'),
config.get('solr_password'))
Expand Down
2 changes: 1 addition & 1 deletion ckan/controllers/feed.py
Expand Up @@ -432,7 +432,7 @@ def _parse_url_params(self):
"""

try:
page = int(request.params.get('page', 1))
page = int(request.params.get('page', 1)) or 1
except ValueError:
abort(400, ('"page" parameter must be an integer'))

Expand Down
12 changes: 9 additions & 3 deletions ckan/controllers/group.py
Expand Up @@ -34,7 +34,7 @@ def _form_to_db_schema(self, group_type=None):
def _db_to_form_schema(self, group_type=None):
'''This is an interface to manipulate data from the database
into a format suitable for the form (optional)'''
return lookup_group_plugin(group_type).form_to_db_schema()
return lookup_group_plugin(group_type).db_to_form_schema()

def _setup_template_variables(self, context, data_dict, group_type=None):
return lookup_group_plugin(group_type).\
Expand Down Expand Up @@ -100,7 +100,7 @@ def read(self, id):
group_type = self._get_group_type(id.split('@')[0])
context = {'model': model, 'session': model.Session,
'user': c.user or c.author,
'schema': self._form_to_db_schema(group_type=group_type),
'schema': self._db_to_form_schema(group_type=group_type),
'for_view': True, 'extras_as_string': True}
data_dict = {'id': id}
# unicode format (decoded from utf8)
Expand Down Expand Up @@ -139,6 +139,7 @@ def read(self, id):
# most search operations should reset the page counter:
params_nopage = [(k, v) for k, v in request.params.items()
if k != 'page']
sort_by = request.params.get('sort', None)

def search_url(params):
url = h.url_for(controller='group', action='read',
Expand Down Expand Up @@ -171,7 +172,7 @@ def pager_url(q=None, page=None):
c.fields = []
search_extras = {}
for (param, value) in request.params.items():
if not param in ['q', 'page'] \
if not param in ['q', 'page', 'sort'] \
and len(value) and not param.startswith('_'):
if not param.startswith('ext_'):
c.fields.append((param, value))
Expand All @@ -189,6 +190,7 @@ def pager_url(q=None, page=None):
'fq': fq,
'facet.field': g.facets,
'rows': limit,
'sort': sort_by,
'start': (page - 1) * limit,
'extras': search_extras
}
Expand All @@ -210,6 +212,9 @@ def pager_url(q=None, page=None):

c.search_facets = query['search_facets']
c.page.items = query['results']

c.sort_by_selected = sort_by

except SearchError, se:
log.error('Group search error: %r', se.args)
c.query_error = True
Expand Down Expand Up @@ -336,6 +341,7 @@ def _save_edit(self, id, context):
tuplize_dict(parse_params(request.params))))
context['message'] = data_dict.get('log_message', '')
data_dict['id'] = id
context['allow_partial_update'] = True
group = get_action('group_update')(context, data_dict)

if id != group['name']:
Expand Down
6 changes: 6 additions & 0 deletions ckan/controllers/package.py
Expand Up @@ -887,6 +887,12 @@ def _parse_recline_state(self, params):
recline_state.pop('height', None)
recline_state['readOnly'] = True

# previous versions of recline setup used elasticsearch_url attribute
# for data api url - see http://trac.ckan.org/ticket/2639
# fix by relocating this to url attribute which is the default location
if 'dataset' in recline_state and 'elasticsearch_url' in recline_state['dataset']:
recline_state['dataset']['url'] = recline_state['dataset']['elasticsearch_url']

# Ensure only the currentView is available
# default to grid view if none specified
if not recline_state.get('currentView', None):
Expand Down
6 changes: 3 additions & 3 deletions ckan/controllers/related.py
Expand Up @@ -28,7 +28,7 @@ def dashboard(self):
try:
page = int(base.request.params.get('page', 1))
except ValueError, e:
abort(400, ('"page" parameter must be an integer'))
base.abort(400, ('"page" parameter must be an integer'))

# Update ordering in the context
query = logic.get_action('related_list')(context,data_dict)
Expand Down Expand Up @@ -67,12 +67,12 @@ def read(self, id):
try:
logic.check_access('related_show', context, data_dict)
except logic.NotAuthorized:
abort(401, _('Not authorized to see this page'))
base.abort(401, _('Not authorized to see this page'))

related = model.Session.query(model.Related).\
filter(model.Related.id == id).first()
if not related:
abort(404, _('The requested related item was not found'))
base.abort(404, _('The requested related item was not found'))

related.view_count = model.Related.view_count + 1

Expand Down
4 changes: 2 additions & 2 deletions ckan/controllers/storage.py
Expand Up @@ -187,7 +187,7 @@ def file(self, label):
fapp = FileApp(filepath, headers=None, **headers)
return fapp(request.environ, self.start_response)
else:
h.redirect_to(file_url)
h.redirect_to(file_url.encode('ascii','ignore'))


class StorageAPIController(BaseController):
Expand Down Expand Up @@ -270,7 +270,7 @@ def get_metadata(self, label):
qualified=False
)
if url.startswith('/'):
url = config.get('ckan.site_url','') + url
url = config.get('ckan.site_url','').rstrip('/') + url

if not self.ofs.exists(bucket, label):
abort(404)
Expand Down
12 changes: 7 additions & 5 deletions ckan/controllers/user.py
Expand Up @@ -107,10 +107,6 @@ def read(self, id=None):
abort(401, _('Not authorized to see this page'))

context['with_related'] = True
try:
user_dict = get_action('user_show')(context,data_dict)
except NotFound:
h.redirect_to(controller='user', action='login', id=None)

self._setup_template_variables(context, data_dict)

Expand Down Expand Up @@ -388,12 +384,18 @@ def request_reset(self):

def perform_reset(self, id):
context = {'model': model, 'session': model.Session,
'user': c.user}
'user': c.user,
'keep_sensitive_data': True}

data_dict = {'id': id}

try:
user_dict = get_action('user_show')(context, data_dict)

# Be a little paranoid, and get rid of sensitive data that's
# not needed.
user_dict.pop('apikey', None)
user_dict.pop('reset_key', None)
user_obj = context['user_obj']
except NotFound, e:
abort(404, _('User not found'))
Expand Down
Binary file modified ckan/i18n/bg/LC_MESSAGES/ckan.mo
Binary file not shown.

0 comments on commit 93bd7ad

Please sign in to comment.