Skip to content

Commit

Permalink
Merge branch 'master' into 3004-upgrade-babel
Browse files Browse the repository at this point in the history
Conflicts:
	requirements.in
  • Loading branch information
amercader committed May 25, 2016
2 parents a8cfc57 + 56ae1bd commit 0397376
Show file tree
Hide file tree
Showing 48 changed files with 698 additions and 249 deletions.
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Dockerfile
Expand Up @@ -53,6 +53,8 @@ ADD ./contrib/docker/my_init.d /etc/my_init.d
ADD ./contrib/docker/svc /etc/service
CMD ["/sbin/my_init"]

# Volumes
VOLUME ["/etc/ckan/default"]
VOLUME ["/var/lib/ckan"]
EXPOSE 80

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -12,8 +12,8 @@ CKAN: The Open Source Data Portal Software
:target: https://stackoverflow.com/questions/tagged/ckan
:alt: Support on StackOverflow

.. image:: https://secure.travis-ci.org/ckan/ckan.png?branch=master
:target: http://travis-ci.org/ckan/ckan
.. image:: https://circleci.com/gh/ckan/ckan.svg?style=shield
:target: https://circleci.com/gh/ckan/ckan
:alt: Build Status

.. image:: https://coveralls.io/repos/github/ckan/ckan/badge.svg?branch=master
Expand Down
3 changes: 1 addition & 2 deletions ckan/controllers/api.py
Expand Up @@ -166,8 +166,7 @@ def action(self, logic_function, ver=None):
_('Action name not known: %s') % logic_function)

context = {'model': model, 'session': model.Session, 'user': c.user,
'api_version': ver, 'return_type': 'LazyJSONObject',
'auth_user_obj': c.userobj}
'api_version': ver, 'auth_user_obj': c.userobj}
model.Session()._context = context

return_dict = {'help': h.url_for(controller='api',
Expand Down
20 changes: 11 additions & 9 deletions ckan/controllers/feed.py
Expand Up @@ -188,24 +188,26 @@ def _group_or_organization(self, obj_dict, is_org):
action=group_type,
id=obj_dict['name'])

guid = _create_atom_id(u'/feeds/group/%s.atom' %
obj_dict['name'])
alternate_url = self._alternate_url(params, groups=obj_dict['name'])
desc = u'Recently created or updated datasets on %s by group: "%s"' %\
(g.site_title, obj_dict['title'])
title = u'%s - Group: "%s"' %\
(g.site_title, obj_dict['title'])

if is_org:
guid = _create_atom_id(u'/feeds/organization/%s.atom' %
obj_dict['name'])
alternate_url = self._alternate_url(params,
organization=obj_dict['name'])
desc = u'Recently created or updated datasets on %s '\
desc = u'Recently created or updated datasets on %s '\
'by organization: "%s"' % (g.site_title, obj_dict['title'])
title = u'%s - Organization: "%s"' %\
(g.site_title, obj_dict['title'])

else: # is group
guid = _create_atom_id(u'/feeds/group/%s.atom' %
obj_dict['name'])
alternate_url = self._alternate_url(params,
groups=obj_dict['name'])
desc = u'Recently created or updated datasets on %s '\
'by group: "%s"' % (g.site_title, obj_dict['title'])
title = u'%s - Group: "%s"' %\
(g.site_title, obj_dict['title'])

return self.output_feed(results,
feed_title=title,
feed_description=desc,
Expand Down
13 changes: 6 additions & 7 deletions ckan/controllers/group.py
Expand Up @@ -159,6 +159,7 @@ def index(self):
sort_by = c.sort_by_selected = request.params.get('sort')
try:
self._check_access('site_read', context)
self._check_access('group_list', context)
except NotAuthorized:
abort(403, _('Not authorized to see this page'))

Expand Down Expand Up @@ -380,10 +381,6 @@ def bulk_process(self, id):
group_type = self._ensure_controller_matches_group_type(
id.split('@')[0])

if group_type != 'organization':
# FIXME: better error
raise Exception('Must be an organization')

# check we are org admin

context = {'model': model, 'session': model.Session,
Expand All @@ -401,6 +398,10 @@ def bulk_process(self, id):
except (NotFound, NotAuthorized):
abort(404, _('Group not found'))

if not c.group_dict['is_organization']:
# FIXME: better error
raise Exception('Must be an organization')

#use different form names so that ie7 can be detected
form_names = set(["bulk_action.public", "bulk_action.delete",
"bulk_action.private"])
Expand Down Expand Up @@ -443,9 +444,7 @@ def bulk_process(self, id):
get_action(action_functions[action])(context, data_dict)
except NotAuthorized:
abort(403, _('Not authorized to perform bulk update'))
base.redirect(h.url_for(controller='organization',
action='bulk_process',
id=id))
self._redirect_to_this_controller(action='bulk_process', id=id)

def new(self, data=None, errors=None, error_summary=None):
if data and 'type' in data:
Expand Down
7 changes: 5 additions & 2 deletions ckan/controllers/package.py
Expand Up @@ -420,7 +420,8 @@ def history(self, id):
h.redirect_to(controller='revision', action='diff', **params)

context = {'model': model, 'session': model.Session,
'user': c.user, 'auth_user_obj': c.userobj}
'user': c.user, 'auth_user_obj': c.userobj,
'for_view': True}
data_dict = {'id': id}
try:
c.pkg_dict = get_action('package_show')(context, data_dict)
Expand Down Expand Up @@ -747,7 +748,9 @@ def edit(self, id, data=None, errors=None, error_summary=None):
if context['save'] and not data:
return self._save_edit(id, context, package_type=package_type)
try:
c.pkg_dict = get_action('package_show')(context, {'id': id})
c.pkg_dict = get_action('package_show')(dict(context,
for_view=True),
{'id': id})
context['for_edit'] = True
old_data = get_action('package_show')(context, {'id': id})
# old data is from the database and data is passed from the
Expand Down
25 changes: 21 additions & 4 deletions ckan/controllers/user.py
Expand Up @@ -35,6 +35,15 @@
unflatten = dictization_functions.unflatten


def set_repoze_user(user_id):
'''Set the repoze.who cookie to match a given user_id'''
if 'repoze.who.plugins' in request.environ:
rememberer = request.environ['repoze.who.plugins']['friendlyform']
identity = {'repoze.who.userid': user_id}
response.headerlist += rememberer.remember(request.environ,
identity)


class UserController(base.BaseController):
def __before__(self, action, **env):
base.BaseController.__before__(self, action, **env)
Expand Down Expand Up @@ -245,10 +254,7 @@ def _save_new(self, context):
return self.new(data_dict, errors, error_summary)
if not c.user:
# log the user in programatically
rememberer = request.environ['repoze.who.plugins']['friendlyform']
identity = {'repoze.who.userid': data_dict['name']}
response.headerlist += rememberer.remember(request.environ,
identity)
set_repoze_user(data_dict['name'])
h.redirect_to(controller='user', action='me', __ckan_no_root=True)
else:
# #1799 User has managed to register whilst logged in - warn user
Expand Down Expand Up @@ -321,6 +327,12 @@ def edit(self, id=None, data=None, errors=None, error_summary=None):

def _save_edit(self, id, context):
try:
if id in (c.userobj.id, c.userobj.name):
current_user = True
else:
current_user = False
old_username = c.userobj.name

data_dict = logic.clean_dict(unflatten(
logic.tuplize_dict(logic.parse_params(request.params))))
context['message'] = data_dict.get('log_message', '')
Expand All @@ -343,6 +355,11 @@ def _save_edit(self, id, context):

user = get_action('user_update')(context, data_dict)
h.flash_success(_('Profile updated'))

if current_user and data_dict['name'] != old_username:
# Changing currently logged in user's name.
# Update repoze.who cookie to match
set_repoze_user(data_dict['name'])
h.redirect_to(controller='user', action='read', id=user['name'])
except NotAuthorized:
abort(403, _('Unauthorized to edit user %s') % id)
Expand Down
41 changes: 4 additions & 37 deletions ckan/lib/helpers.py
Expand Up @@ -54,8 +54,8 @@ def __init__(self, *args, **kwargs):

def __getitem__(self, key):
try:
value = super(HelperAttributeDict, self).__getitem__(self, key)
except AttributeError:
value = super(HelperAttributeDict, self).__getitem__(key)
except KeyError:
raise ckan.exceptions.HelperError(
'Helper \'{key}\' has not been defined.'.format(
key=key
Expand Down Expand Up @@ -720,7 +720,8 @@ def get_facet_items_dict(facet, limit=None, exclude_active=False):
facets.append(dict(active=False, **facet_item))
elif not exclude_active:
facets.append(dict(active=True, **facet_item))
facets = sorted(facets, key=lambda item: item['count'], reverse=True)
# Sort descendingly by count and ascendingly by case-sensitive display name
facets.sort(key=lambda it: (-it['count'], it['display_name'].lower()))
if c.search_facets_limits and limit is None:
limit = c.search_facets_limits.get(facet)
# zero treated as infinite for hysterical raisins
Expand Down Expand Up @@ -1579,40 +1580,6 @@ def debug_inspect(arg):
return literal('<pre>') + pprint.pformat(arg) + literal('</pre>')


@core_helper
def debug_full_info_as_list(debug_info):
''' This dumps the template variables for debugging purposes only. '''
out = []
ignored_keys = ['c', 'app_globals', 'g', 'h', 'request', 'tmpl_context',
'actions', 'translator', 'session', 'N_', 'ungettext',
'config', 'response', '_']
ignored_context_keys = ['__class__', '__context', '__delattr__',
'__dict__',
'__doc__', '__format__', '__getattr__',
'__getattribute__', '__hash__', '__init__',
'__module__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str__', '__subclasshook__',
'__weakref__', 'action', 'environ', 'pylons',
'start_response']
debug_vars = debug_info['vars']
for key in debug_vars.keys():
if key not in ignored_keys:
data = pprint.pformat(debug_vars.get(key))
data = data.decode('utf-8')
out.append((key, data))

if 'tmpl_context' in debug_vars:
for key in debug_info['c_vars']:

if key not in ignored_context_keys:
data = pprint.pformat(getattr(debug_vars['tmpl_context'], key))
data = data.decode('utf-8')
out.append(('c.%s' % key, data))

return out


@core_helper
def popular(type_, number, min=1, title=None):
''' display a popular icon. '''
Expand Down
5 changes: 4 additions & 1 deletion ckan/lib/jinja_extensions.py
Expand Up @@ -62,7 +62,10 @@ class CkanInternationalizationExtension(ext.InternationalizationExtension):

def parse(self, parser):
node = ext.InternationalizationExtension.parse(self, parser)
args = getattr(node.nodes[0], 'args', None)
if isinstance(node, list):
args = getattr(node[1].nodes[0], 'args', None)
else:
args = getattr(node.nodes[0], 'args', None)
if args:
for arg in args:
if isinstance(arg, nodes.Const):
Expand Down
59 changes: 0 additions & 59 deletions ckan/lib/lazyjson.py

This file was deleted.

2 changes: 1 addition & 1 deletion ckan/lib/munge.py
Expand Up @@ -139,7 +139,7 @@ def munge_filename(filename):
# clean up
filename = substitute_ascii_equivalents(filename)
filename = filename.lower().strip()
filename = re.sub(r'[^a-zA-Z0-9. -]', '', filename).replace(' ', '-')
filename = re.sub(r'[^a-zA-Z0-9_. -]', '', filename).replace(' ', '-')
# resize if needed but keep extension
name, ext = os.path.splitext(filename)
# limit overly long extensions
Expand Down

0 comments on commit 0397376

Please sign in to comment.