当前位置: 首页>>代码示例>>Python>>正文


Python Authorizer.is_sysadmin方法代码示例

本文整理汇总了Python中ckan.authz.Authorizer.is_sysadmin方法的典型用法代码示例。如果您正苦于以下问题:Python Authorizer.is_sysadmin方法的具体用法?Python Authorizer.is_sysadmin怎么用?Python Authorizer.is_sysadmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ckan.authz.Authorizer的用法示例。


在下文中一共展示了Authorizer.is_sysadmin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ignore_not_package_admin

# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import is_sysadmin [as 别名]
def ignore_not_package_admin(key, data, errors, context):
    '''Ignore if the user is not allowed to administer the package specified.'''

    model = context['model']
    user = context.get('user')

    if 'ignore_auth' in context:
        return

    if user and Authorizer.is_sysadmin(user):
        return

    authorized = False
    pkg = context.get('package')
    if pkg:
        try:
            check_access('package_change_state',context)
            authorized = True
        except NotAuthorized:
            authorized = False

    if (user and pkg and authorized):
        return

    data.pop(key)
开发者ID:Open-Source-GIS,项目名称:ckan,代码行数:27,代码来源:validators.py

示例2: group_create

# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import is_sysadmin [as 别名]
def group_create(context, data_dict=None):
    """
    Group create permission.  If a group is provided, within which we want to create a group
    then we check that the user is within that group.  If not then we just say Yes for now
    although there may be some approval issues elsewhere.
    """
    model = context['model']
    user  = context['user']

    if not model.User.get(user):
        return {'success': False, 'msg': _('User is not authorized to create groups') }

    if Authorizer.is_sysadmin(user):
        return {'success': True}

    try:
        # If the user is doing this within another group then we need to make sure that
        # the user has permissions for this group.
        group = get_group_object( context )
    except logic.NotFound:
        return { 'success' : True }

    userobj = model.User.get( user )
    if not userobj:
        return {'success': False, 'msg': _('User %s not authorized to create groups') % str(user)}

    authorized = _groups_intersect( userobj.get_groups('organization'), [group] )
    if not authorized:
        return {'success': False, 'msg': _('User %s not authorized to create groups') % str(user)}
    else:
        return {'success': True}
开发者ID:jmwenda,项目名称:ckan,代码行数:33,代码来源:create.py

示例3: ignore_not_package_admin

# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import is_sysadmin [as 别名]
def ignore_not_package_admin(key, data, errors, context):
    '''Ignore if the user is not allowed to administer the package specified.'''

    model = context['model']
    user = context.get('user')

    if 'ignore_auth' in context:
        return

    if user and Authorizer.is_sysadmin(user):
        return

    authorized = False
    pkg = context.get('package')
    if pkg:
        try:
            check_access('package_change_state',context)
            authorized = True
        except NotAuthorized:
            authorized = False

    if (user and pkg and authorized):
        return

    # allow_state_change in the context will allow the state to be changed
    # FIXME is this the best way to cjeck for state only?
    if key == ('state',) and context.get('allow_state_change'):
        return
    data.pop(key)
开发者ID:Big-Data,项目名称:ckan,代码行数:31,代码来源:validators.py

示例4: ignore_not_admin

# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import is_sysadmin [as 别名]
def ignore_not_admin(key, data, errors, context):

    model = context['model']
    user = context.get('user')

    if user and Authorizer.is_sysadmin(user):
        return

    pkg = context.get('package')
    if (user and pkg and 
        Authorizer().is_authorized(user, model.Action.CHANGE_STATE, pkg)):
        return

    data.pop(key)
开发者ID:AdamJensen-dk,项目名称:ckan-drupal,代码行数:16,代码来源:validators.py

示例5: ignore_not_admin

# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import is_sysadmin [as 别名]
def ignore_not_admin(key, data, errors, context):

    model = context['model']
    user = context.get('user')

    if user and Authorizer.is_sysadmin(user):
        return

    authorized = False
    pkg = context.get('package')
    if pkg:
        try:
            check_access('package_change_state',context)
            authorized = True
        except NotAuthorized:
            authorized = False
    
    if (user and pkg and authorized):
        return

    data.pop(key)
开发者ID:kindly,项目名称:ckantest,代码行数:23,代码来源:validators.py

示例6: ignore_not_group_admin

# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import is_sysadmin [as 别名]
def ignore_not_group_admin(key, data, errors, context):
    '''Ignore if the user is not allowed to administer for the group specified.'''

    model = context['model']
    user = context.get('user')

    if user and Authorizer.is_sysadmin(user):
        return

    authorized = False
    group = context.get('group')
    if group:
        try:
            check_access('group_change_state',context)
            authorized = True
        except NotAuthorized:
            authorized = False

    if (user and group and authorized):
        return

    data.pop(key)
开发者ID:Open-Source-GIS,项目名称:ckan,代码行数:24,代码来源:validators.py

示例7: tag_delete

# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import is_sysadmin [as 别名]
def tag_delete(context, data_dict):
    user = context['user']
    return {'success': Authorizer.is_sysadmin(user)}
开发者ID:emphanos,项目名称:ckan,代码行数:5,代码来源:delete.py

示例8: vocabulary_update

# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import is_sysadmin [as 别名]
def vocabulary_update(context, data_dict):
    user = context['user']
    return {'success': Authorizer.is_sysadmin(user)}
开发者ID:Big-Data,项目名称:ckan,代码行数:5,代码来源:update.py

示例9: activity_create

# 需要导入模块: from ckan.authz import Authorizer [as 别名]
# 或者: from ckan.authz.Authorizer import is_sysadmin [as 别名]
def activity_create(context, data_dict):
    user = context['user']
    return {'success': Authorizer.is_sysadmin(user)}
开发者ID:jmwenda,项目名称:ckan,代码行数:5,代码来源:create.py


注:本文中的ckan.authz.Authorizer.is_sysadmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。