Skip to content

Commit

Permalink
Merge branch 'master' into 1226-user-create-option
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/logic/auth/create.py
	ckan/templates/header.html
  • Loading branch information
nigelbabu committed Oct 14, 2013
2 parents 878772c + b218294 commit c269023
Show file tree
Hide file tree
Showing 205 changed files with 9,934 additions and 7,083 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Expand Up @@ -93,7 +93,7 @@ Deprecated and removed:
one. Please update your config files if using it. (#226)

Known issues:
* Under certain authorization setups the forntend for the groups functionality
* Under certain authorization setups the frontend for the groups functionality
may not work as expected (See #1176 #1175).


Expand Down
15 changes: 9 additions & 6 deletions CONTRIBUTING.rst
Expand Up @@ -44,6 +44,7 @@ For contributing translations to CKAN, see

i18n

.. _coding standards:

----------------
Coding Standards
Expand All @@ -59,12 +60,14 @@ When writing code for CKAN, try to respect our coding standards:
html-coding-standards
css-coding-standards
javascript-coding-standards

* `CKAN Coding Standards <http://docs.ckan.org/en/latest/ckan-coding-standards.html>`_
* `Python Coding Standards <http://docs.ckan.org/en/latest/python-coding-standards.html>`_
* `HTML Coding Standards <http://docs.ckan.org/en/latest/html-coding-standards.html>`_
* `CSS Coding Standards <http://docs.ckan.org/en/latest/css-coding-standards.html>`_
* `JavaScript Coding Standards <http://docs.ckan.org/en/latest/javascript-coding-standards.html>`_
testing-coding-standards

* `CKAN coding standards <http://docs.ckan.org/en/latest/ckan-coding-standards.html>`_
* `Python coding standards <http://docs.ckan.org/en/latest/python-coding-standards.html>`_
* `HTML coding standards <http://docs.ckan.org/en/latest/html-coding-standards.html>`_
* `CSS coding standards <http://docs.ckan.org/en/latest/css-coding-standards.html>`_
* `JavaScript coding standards <http://docs.ckan.org/en/latest/javascript-coding-standards.html>`_
* `Testing coding standards <http://docs.ckan.org/en/latest/testing-coding-standards.html>`_


---------------
Expand Down
6 changes: 5 additions & 1 deletion ckan/ckan_nose_plugin.py
Expand Up @@ -17,6 +17,10 @@ def startContext(self, ctx):
# import needs to be here or setup happens too early
import ckan.model as model

if 'new_tests' in repr(ctx):
# We don't want to do the stuff below for new-style tests.
return

if isclass(ctx):
if hasattr(ctx, "no_db") and ctx.no_db:
return
Expand All @@ -38,7 +42,7 @@ def startContext(self, ctx):
from ckan.plugins.interfaces import IConfigurable
for plugin in PluginImplementations(IConfigurable):
plugin.configure(config)

model.repo.init_db()

def options(self, parser, env):
Expand Down
9 changes: 9 additions & 0 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -134,6 +134,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
15 changes: 12 additions & 3 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 All @@ -31,6 +34,11 @@ def _get_config_form_items(self):
{'text': 'Green', 'value': '/base/css/green.css'},
{'text': 'Maroon', 'value': '/base/css/maroon.css'},
{'text': 'Fuchsia', 'value': '/base/css/fuchsia.css'}]

homepages = [{'value': '1', 'text': 'Introductory area, search, featured group and featured organization'},
{'value': '2', 'text': 'Search, stats, introductory area, featured organization and featured group'},
{'value': '3', 'text': 'Search, introductory area and stats'}]

items = [
{'name': 'ckan.site_title', 'control': 'input', 'label': _('Site Title'), 'placeholder': ''},
{'name': 'ckan.main_css', 'control': 'select', 'options': styles, 'label': _('Style'), 'placeholder': ''},
Expand All @@ -39,6 +47,7 @@ def _get_config_form_items(self):
{'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')},
{'name': 'ckan.homepage_style', 'control': 'select', 'options': homepages, 'label': _('Homepage'), 'placeholder': ''},
]
return items

Expand Down Expand Up @@ -149,4 +158,4 @@ def trash(self):

for msg in msgs:
h.flash_error(msg)
h.redirect_to(h.url_for('ckanadmin', action='trash'))
h.redirect_to(controller='admin', action='trash')
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 c269023

Please sign in to comment.