Skip to content

Commit

Permalink
[#2939] Group controller _check_access helper added
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Sep 28, 2012
1 parent ccf58e3 commit 8350e90
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ckan/controllers/group.py
Expand Up @@ -69,6 +69,10 @@ def _action(self, action_name):
''' select the correct group/org action '''
return get_action(self._replace_group_org(action_name))

def _check_access(self, action_name, *args, **kw):
''' select the correct group/org check_access '''
return check_access(self._replace_group_org(action_name), *args, **kw)

def _render_template(self, template_name):
''' render the correct group/org template '''
return render(self._replace_group_org(template_name))
Expand Down Expand Up @@ -112,7 +116,7 @@ def index(self):
data_dict = {'all_fields': True}

try:
check_access('site_read', context)
self._check_access('site_read', context)
except NotAuthorized:
abort(401, _('Not authorized to see this page'))

Expand Down Expand Up @@ -279,7 +283,7 @@ def new(self, data=None, errors=None, error_summary=None):
'save': 'save' in request.params,
'parent': request.params.get('parent', None)}
try:
check_access('group_create', context)
self._check_access('group_create', context)
except NotAuthorized:
abort(401, _('Unauthorized to create a group'))

Expand Down Expand Up @@ -324,7 +328,7 @@ def edit(self, id, data=None, errors=None, error_summary=None):
c.group = group

try:
check_access('group_update', context)
self._check_access('group_update', context)
except NotAuthorized, e:
abort(401, _('User %r not authorized to edit %s') % (c.user, id))

Expand Down Expand Up @@ -411,7 +415,7 @@ def authz(self, id):
try:
context = \
{'model': model, 'user': c.user or c.author, 'group': group}
check_access('group_edit_permissions', context)
self._check_access('group_edit_permissions', context)
c.authz_editable = True
c.group = context['group']
except NotAuthorized:
Expand All @@ -433,7 +437,7 @@ def delete(self, id):
'user': c.user or c.author}

try:
check_access('group_delete', context, {'id': id})
self._check_access('group_delete', context, {'id': id})
except NotAuthorized:
abort(401, _('Unauthorized to delete group %s') % '')

Expand Down

0 comments on commit 8350e90

Please sign in to comment.