예제 #1
0
 def secure(self, func):
     '''Enforce authentication on a given method/verb and optionnaly check a given permission'''
     if isinstance(func, basestring):
         return self._apply_permission(Permission(RoleNeed(func)))
     elif isinstance(func, Permission):
         return self._apply_permission(func)
     else:
         return self._apply_secure(func)
예제 #2
0
from udata.auth import Permission, RoleNeed, UserNeed
from udata.i18n import lazy_gettext as _

ROLES = {
    'admin': _('System administrator'),
    'editor': _('Site editorialist'),
    'moderator': _('Site moderator'),
}

sysadmin = Permission(RoleNeed('admin'))


class UserEditPermission(Permission):
    def __init__(self, user):
        need = UserNeed(user.id)
        super(UserEditPermission, self).__init__(need)