Skip to content

Commit

Permalink
Merge branch 'master' of github.com:okfn/ckan into 1038-organization-…
Browse files Browse the repository at this point in the history
…hierarchy

Conflicts:
	ckan/logic/validators.py
  • Loading branch information
David Read committed Sep 17, 2013
2 parents 24548c0 + ba560b9 commit e0bc490
Show file tree
Hide file tree
Showing 82 changed files with 5,949 additions and 2,371 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Expand Up @@ -44,6 +44,7 @@ For contributing translations to CKAN, see

i18n

.. _coding standards:

----------------
Coding Standards
Expand Down
10 changes: 9 additions & 1 deletion ckan/config/deployment.ini_tmpl
Expand Up @@ -67,7 +67,6 @@ ckan.auth.user_delete_groups = true
ckan.auth.user_delete_organizations = true
ckan.auth.create_user_via_api = false


## Search Settings

ckan.site_id = default
Expand Down Expand Up @@ -133,6 +132,15 @@ ckan.feeds.author_link =
#ofs.aws_access_key_id = ....
#ofs.aws_secret_access_key = ....

# 'Bucket' to use for file storage
#ckan.storage.bucket = default

# Prefix for uploaded files (only used for pairtree)
#ckan.storage.key_prefix = file/

# The maximum content size, in bytes, for uploads
#ckan.storage.max_content_length = 50000000

## Datapusher settings

# Make sure you have set up the DataStore
Expand Down
7 changes: 5 additions & 2 deletions ckan/controllers/admin.py
Expand Up @@ -4,6 +4,7 @@
import ckan.lib.helpers as h
import ckan.lib.app_globals as app_globals
import ckan.model as model
import ckan.logic as logic
import ckan.new_authz

c = base.c
Expand All @@ -19,8 +20,10 @@ class AdminController(base.BaseController):
def __before__(self, action, **params):
super(AdminController, self).__before__(action, **params)
context = {'model': model,
'user': c.user}
if not ckan.new_authz.is_authorized('sysadmin', context, {})['success']:
'user': c.user, 'auth_user_obj': c.userobj}
try:
logic.check_access('sysadmin', context, {})
except logic.NotAuthorized:
base.abort(401, _('Need to be system administrator to administer'))
c.revision_change_state_allowed = True

Expand Down
26 changes: 14 additions & 12 deletions ckan/controllers/api.py
Expand Up @@ -52,7 +52,8 @@ def __call__(self, environ, start_response):

self._identify_user()
try:
context = {'model': model, 'user': c.user or c.author}
context = {'model': model, 'user': c.user or c.author,
'auth_user_obj': c.userobj}
logic.check_access('site_read', context)
except NotAuthorized:
response_msg = self._finish(403,
Expand Down Expand Up @@ -161,7 +162,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}
'api_version': ver, 'auth_user_obj': c.userobj}
model.Session()._context = context
return_dict = {'help': function.__doc__}
try:
Expand Down Expand Up @@ -248,7 +249,8 @@ def _get_action_from_map(self, action_map, register, subregister):

def list(self, ver=None, register=None, subregister=None, id=None):
context = {'model': model, 'session': model.Session,
'user': c.user, 'api_version': ver}
'user': c.user, 'api_version': ver,
'auth_user_obj': c.userobj}
log.debug('listing: %s' % context)
action_map = {
'revision': 'revision_list',
Expand Down Expand Up @@ -292,7 +294,7 @@ def show(self, ver=None, register=None, subregister=None,
action_map[('dataset', type)] = 'package_relationships_list'

context = {'model': model, 'session': model.Session, 'user': c.user,
'api_version': ver}
'api_version': ver, 'auth_user_obj': c.userobj}
data_dict = {'id': id, 'id2': id2, 'rel': subregister}

log.debug('show: %s' % context)
Expand Down Expand Up @@ -327,7 +329,7 @@ def create(self, ver=None, register=None, subregister=None,
action_map[('dataset', type)] = 'package_relationship_create_rest'

context = {'model': model, 'session': model.Session, 'user': c.user,
'api_version': ver}
'api_version': ver, 'auth_user_obj': c.userobj}
log.debug('create: %s' % (context))
try:
request_data = self._get_request_data()
Expand Down Expand Up @@ -390,7 +392,7 @@ def update(self, ver=None, register=None, subregister=None,
action_map[('dataset', type)] = 'package_relationship_update_rest'

context = {'model': model, 'session': model.Session, 'user': c.user,
'api_version': ver, 'id': id}
'api_version': ver, 'id': id, 'auth_user_obj': c.userobj}
log.debug('update: %s' % (context))
try:
request_data = self._get_request_data()
Expand Down Expand Up @@ -442,7 +444,7 @@ def delete(self, ver=None, register=None, subregister=None,
action_map[('dataset', type)] = 'package_relationship_delete_rest'

context = {'model': model, 'session': model.Session, 'user': c.user,
'api_version': ver}
'api_version': ver, 'auth_user_obj': c.userobj}

data_dict = {'id': id, 'id2': id2, 'rel': subregister}

Expand Down Expand Up @@ -597,7 +599,7 @@ def tag_counts(self, ver=None):
c.q = request.params.get('q', '')

context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
'user': c.user or c.author, 'auth_user_obj': c.userobj}

tag_names = get_action('tag_list')(context, {})
results = []
Expand Down Expand Up @@ -632,7 +634,7 @@ def user_autocomplete(self):
user_list = []
if q:
context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
'user': c.user or c.author, 'auth_user_obj': c.userobj}

data_dict = {'q': q, 'limit': limit}

Expand Down Expand Up @@ -696,7 +698,7 @@ def dataset_autocomplete(self):
package_dicts = []
if q:
context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
'user': c.user or c.author, 'auth_user_obj': c.userobj}

data_dict = {'q': q, 'limit': limit}

Expand All @@ -712,7 +714,7 @@ def tag_autocomplete(self):
tag_names = []
if q:
context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
'user': c.user or c.author, 'auth_user_obj': c.userobj}

data_dict = {'q': q, 'limit': limit}

Expand All @@ -731,7 +733,7 @@ def format_autocomplete(self):
formats = []
if q:
context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
'user': c.user or c.author, 'auth_user_obj': c.userobj}
data_dict = {'q': q, 'limit': limit}
formats = get_action('format_autocomplete')(context, data_dict)

Expand Down
4 changes: 2 additions & 2 deletions ckan/controllers/feed.py
Expand Up @@ -47,7 +47,7 @@ def _package_search(data_dict):
* unless overridden, sets a default item limit
"""
context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
'user': c.user or c.author, 'auth_user_obj': c.userobj}

if 'sort' not in data_dict or not data_dict['sort']:
data_dict['sort'] = 'metadata_modified desc'
Expand Down Expand Up @@ -170,7 +170,7 @@ def _alternate_url(self, params, **kwargs):
def group(self, id):
try:
context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
'user': c.user or c.author, 'auth_user_obj': c.userobj}
group_dict = logic.get_action('group_show')(context, {'id': id})
except logic.NotFound:
base.abort(404, _('Group not found'))
Expand Down
6 changes: 4 additions & 2 deletions ckan/controllers/home.py
Expand Up @@ -22,7 +22,8 @@ class HomeController(base.BaseController):
def __before__(self, action, **env):
try:
base.BaseController.__before__(self, action, **env)
context = {'model': model, 'user': c.user or c.author}
context = {'model': model, 'user': c.user or c.author,
'auth_user_obj': c.userobj}
logic.check_access('site_read', context)
except logic.NotAuthorized:
base.abort(401, _('Not authorized to see this page'))
Expand All @@ -43,7 +44,7 @@ def index(self):
try:
# package search
context = {'model': model, 'session': model.Session,
'user': c.user or c.author}
'user': c.user or c.author, 'auth_user_obj': c.userobj}
data_dict = {
'q': '*:*',
'facet.field': g.facets,
Expand Down Expand Up @@ -129,6 +130,7 @@ def db_to_form_schema(group_type=None):
context = {'model': model, 'session': model.Session,
'ignore_auth': True,
'user': c.user or c.author,
'auth_user_obj': c.userobj,
'schema': db_to_form_schema(group_type=group_type),
'limits': {'packages': 2},
'for_view': True}
Expand Down

0 comments on commit e0bc490

Please sign in to comment.