Skip to content

Commit

Permalink
[#2939] Fix for admin controller
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Oct 3, 2012
1 parent 2954167 commit 8068853
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ckan/controllers/admin.py
Expand Up @@ -6,6 +6,7 @@
import ckan.authz
import ckan.lib.authztool
import ckan.model as model
import ckan.logic

from ckan.model.authz import Role
roles = Role.get_all()
Expand All @@ -17,14 +18,16 @@
_ = base._

def get_sysadmins():
q = model.Session.query(model.SystemRole).filter_by(role=model.Role.ADMIN)
return [uor.user for uor in q.all() if uor.user]
q = model.Session.query(model.User).filter(model.User.sysadmin==True)
return q.all()


class AdminController(base.BaseController):
def __before__(self, action, **params):
super(AdminController, self).__before__(action, **params)
if not ckan.authz.Authorizer().is_sysadmin(unicode(c.user)):
context = {'model': model,
'user': c.user}
if not ckan.logic.check_access('sysadmin', context, {}):
base.abort(401, _('Need to be system administrator to administer'))
c.revision_change_state_allowed = (
c.user and self.authorizer.is_authorized(c.user,
Expand Down

0 comments on commit 8068853

Please sign in to comment.