Skip to content

Commit

Permalink
Merge branch 'release-datagov' of github.com:okfn/ckan into release-d…
Browse files Browse the repository at this point in the history
…atagov
  • Loading branch information
kindly committed Apr 23, 2013
2 parents ea0256c + ce94d35 commit 45b1372
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 46 deletions.
12 changes: 12 additions & 0 deletions ckan/logic/__init__.py
Expand Up @@ -383,6 +383,18 @@ def wrapper(context, data_dict):
return wrapper


def auth_sysadmins_check(action):
''' Prevent sysadmins from automatically being authenticated. Instead
they are treated like any other user and the auth function is called.
'''
@functools.wraps(action)
def wrapper(context, data_dict):
return action(context, data_dict)
wrapper.auth_sysadmins_check = True
return wrapper



class UnknownValidator(Exception):
pass

Expand Down
21 changes: 14 additions & 7 deletions ckan/logic/auth/__init__.py
Expand Up @@ -11,16 +11,23 @@ def _get_object(context, data_dict, name, class_name):
try:
return context[name]
except KeyError:
model = context['model']
if not data_dict:
data_dict = {}
id = data_dict.get('id', None)
obj = getattr(model, class_name).get(id)
if not obj:
raise logic.NotFound
# Save in case we need this again during the request
context[name] = obj
return obj
key = '_OBJECT_STORE_%s__%s' % (name, id)
# This is our cache key to prevent multiple database calls. Perhaps
# this is a bit too much magic but it feels quite self contained and
# safer that the using current data_dict['id'] magic.
try:
return context[key]
except KeyError:
model = context['model']
obj = getattr(model, class_name).get(id)
if not obj:
raise logic.NotFound
# Save in case we need this again during the request
context[key] = obj
return obj


def get_related_object(context, data_dict=None):
Expand Down
11 changes: 7 additions & 4 deletions ckan/new_authz.py
Expand Up @@ -58,12 +58,15 @@ def is_authorized(action, context, data_dict=None):
if context.get('ignore_auth'):
return {'success': True}

# sysadmins can do anything
if is_sysadmin(context.get('user')):
return {'success': True}

auth_function = _get_auth_function(action)
if auth_function:
# sysadmins can do anything unless the auth_sysadmins_check
# decorator was used in which case they are treated like all other
# users.
if is_sysadmin(context.get('user')):
if not getattr(auth_function, 'auth_sysadmins_check', False):
return {'success': True}

return auth_function(context, data_dict)
else:
raise ValueError(_('Authorization function not found: %s' % action))
Expand Down
25 changes: 15 additions & 10 deletions ckan/public/base/css/fuchsia.css
Expand Up @@ -4860,8 +4860,6 @@ a.tag:hover {
}
.box {
background-color: #FFF;
margin-left: -1px;
margin-right: -1px;
border: 1px solid #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
Expand Down Expand Up @@ -6515,6 +6513,11 @@ textarea {
-moz-border-radius-bottomright: 2px;
border-bottom-right-radius: 2px;
}
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ckan-icon {
*margin-right: .3em;
display: inline-block;
Expand Down Expand Up @@ -7659,8 +7662,6 @@ textarea {
.wrapper {
*zoom: 1;
background-color: #FFF;
margin-left: -1px;
margin-right: -1px;
border: 1px solid #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
Expand Down Expand Up @@ -7700,8 +7701,7 @@ textarea {
border-top-width: 1px;
}
[role=main] .primary {
width: 719px;
margin-left: 1px;
width: 717px;
float: right;
}
[role=main] .secondary {
Expand Down Expand Up @@ -8197,10 +8197,15 @@ textarea {
.footer-links {
margin-left: 0;
}
.footer-links li {
display: inline-block;
width: 44%;
margin-right: 5%;
.footer-links ul {
float: left;
margin-left: 20px;
width: 220px;
}
.footer-links ul:first-child {
margin-left: 0;
}
.footer-links ul li {
margin-bottom: 5px;
}
.attribution small {
Expand Down
2 changes: 1 addition & 1 deletion ckan/public/base/css/fuchsia.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ckan/public/base/css/main.debug.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ckan/public/base/css/main.min.css

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions ckan/public/base/css/maroon.css
Expand Up @@ -4860,8 +4860,6 @@ a.tag:hover {
}
.box {
background-color: #FFF;
margin-left: -1px;
margin-right: -1px;
border: 1px solid #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
Expand Down Expand Up @@ -6515,6 +6513,11 @@ textarea {
-moz-border-radius-bottomright: 2px;
border-bottom-right-radius: 2px;
}
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ckan-icon {
*margin-right: .3em;
display: inline-block;
Expand Down Expand Up @@ -7659,8 +7662,6 @@ textarea {
.wrapper {
*zoom: 1;
background-color: #FFF;
margin-left: -1px;
margin-right: -1px;
border: 1px solid #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
Expand Down Expand Up @@ -7700,8 +7701,7 @@ textarea {
border-top-width: 1px;
}
[role=main] .primary {
width: 719px;
margin-left: 1px;
width: 717px;
float: right;
}
[role=main] .secondary {
Expand Down Expand Up @@ -8197,10 +8197,15 @@ textarea {
.footer-links {
margin-left: 0;
}
.footer-links li {
display: inline-block;
width: 44%;
margin-right: 5%;
.footer-links ul {
float: left;
margin-left: 20px;
width: 220px;
}
.footer-links ul:first-child {
margin-left: 0;
}
.footer-links ul li {
margin-bottom: 5px;
}
.attribution small {
Expand Down
2 changes: 1 addition & 1 deletion ckan/public/base/css/maroon.min.css

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions ckan/public/base/css/red.css
Expand Up @@ -4860,8 +4860,6 @@ a.tag:hover {
}
.box {
background-color: #FFF;
margin-left: -1px;
margin-right: -1px;
border: 1px solid #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
Expand Down Expand Up @@ -6515,6 +6513,11 @@ textarea {
-moz-border-radius-bottomright: 2px;
border-bottom-right-radius: 2px;
}
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ckan-icon {
*margin-right: .3em;
display: inline-block;
Expand Down Expand Up @@ -7659,8 +7662,6 @@ textarea {
.wrapper {
*zoom: 1;
background-color: #FFF;
margin-left: -1px;
margin-right: -1px;
border: 1px solid #cccccc;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
Expand Down Expand Up @@ -7700,8 +7701,7 @@ textarea {
border-top-width: 1px;
}
[role=main] .primary {
width: 719px;
margin-left: 1px;
width: 717px;
float: right;
}
[role=main] .secondary {
Expand Down Expand Up @@ -8197,10 +8197,15 @@ textarea {
.footer-links {
margin-left: 0;
}
.footer-links li {
display: inline-block;
width: 44%;
margin-right: 5%;
.footer-links ul {
float: left;
margin-left: 20px;
width: 220px;
}
.footer-links ul:first-child {
margin-left: 0;
}
.footer-links ul li {
margin-bottom: 5px;
}
.attribution small {
Expand Down
2 changes: 1 addition & 1 deletion ckan/public/base/css/red.min.css

Large diffs are not rendered by default.

0 comments on commit 45b1372

Please sign in to comment.