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


Python auth.get_permission_codename方法代码示例

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


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

示例1: has_view_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_view_permission(self, request, obj=None):
        """
        Return True if the given request has permission to view the given
        Django model instance. The default implementation doesn't examine the
        `obj` parameter.

        If overridden by the user in subclasses, it should return True if the
        given request has permission to view the `obj` model instance. If `obj`
        is None, it should return True if the request has permission to view
        any object of the given type.
        """
        opts = self.opts
        codename_view = get_permission_codename('view', opts)
        codename_change = get_permission_codename('change', opts)
        return (
            request.user.has_perm('%s.%s' % (opts.app_label, codename_view)) or
            request.user.has_perm('%s.%s' % (opts.app_label, codename_change))
        ) 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:20,代码来源:options.py

示例2: has_view_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_view_permission(self, obj=None):
        view_codename = get_permission_codename('view', self.opts)
        change_codename = get_permission_codename('change', self.opts)

        return ('view' not in self.remove_permissions) and (self.user.has_perm('%s.%s' % (self.app_label, view_codename)) or \
            self.user.has_perm('%s.%s' % (self.app_label, change_codename))) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:8,代码来源:base.py

示例3: has_add_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_add_permission(self):
        codename = get_permission_codename('add', self.opts)
        return ('add' not in self.remove_permissions) and self.user.has_perm('%s.%s' % (self.app_label, codename)) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:5,代码来源:base.py

示例4: has_change_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_change_permission(self, obj=None):
        codename = get_permission_codename('change', self.opts)
        return ('change' not in self.remove_permissions) and self.user.has_perm('%s.%s' % (self.app_label, codename)) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:5,代码来源:base.py

示例5: has_delete_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_delete_permission(self, obj=None):
        codename = get_permission_codename('delete', self.opts)
        return ('delete' not in self.remove_permissions) and self.user.has_perm('%s.%s' % (self.app_label, codename)) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:5,代码来源:base.py

示例6: has_add_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_add_permission(self):
        if self.opts.auto_created:
            return self.has_change_permission()

        codename = get_permission_codename('add', self.opts)
        return self.user.has_perm("%s.%s" % (self.opts.app_label, codename)) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:8,代码来源:inline.py

示例7: has_delete_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_delete_permission(self):
        if self.opts.auto_created:
            return self.has_change_permission()

        codename = get_permission_codename('delete', self.opts)
        return self.user.has_perm("%s.%s" % (self.opts.app_label, codename)) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:8,代码来源:inline.py

示例8: has_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_permission(opts, user, perm):
    codename = get_permission_codename(perm, opts)
    return user.has_perm("%s.%s" % (opts.app_label, codename)) 
开发者ID:Wenvki,项目名称:django-idcops,代码行数:5,代码来源:utils.py

示例9: get_actions

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def get_actions(opts, user):
    actions = []
    name = opts.model_name.lower()
    ACTION_PATH = 'idcops.actions'
    try:
        action_list = import_string("{}.{}".format(ACTION_PATH, name))
    except BaseException:
        action_list = import_string("{}.general".format(ACTION_PATH))
    for a in action_list:
        action = get_action(import_string("{}.{}".format(ACTION_PATH, a)))
        perm, _, _, _ = action
        p = '%s.%s' % (opts.app_label, get_permission_codename(perm, opts))
        if user.has_perm(p):
            actions.append(action)
    return actions 
开发者ID:Wenvki,项目名称:django-idcops,代码行数:17,代码来源:utils.py

示例10: has_add_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_add_permission(self, request):
        """
        Returns True if the given request has permission to add an object.
        Can be overridden by the user in subclasses.
        """
        opts = self.opts
        codename = get_permission_codename('add', opts)
        return request.user.has_perm("%s.%s" % (opts.app_label, codename)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:10,代码来源:options.py

示例11: has_change_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_change_permission(self, request, obj=None):
        """
        Returns True if the given request has permission to change the given
        Django model instance, the default implementation doesn't examine the
        `obj` parameter.

        Can be overridden by the user in subclasses. In such case it should
        return True if the given request has permission to change the `obj`
        model instance. If `obj` is None, this should return True if the given
        request has permission to change *any* object of the given type.
        """
        opts = self.opts
        codename = get_permission_codename('change', opts)
        return request.user.has_perm("%s.%s" % (opts.app_label, codename)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:16,代码来源:options.py

示例12: has_delete_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_delete_permission(self, request, obj=None):
        """
        Returns True if the given request has permission to change the given
        Django model instance, the default implementation doesn't examine the
        `obj` parameter.

        Can be overridden by the user in subclasses. In such case it should
        return True if the given request has permission to delete the `obj`
        model instance. If `obj` is None, this should return True if the given
        request has permission to delete *any* object of the given type.
        """
        opts = self.opts
        codename = get_permission_codename('delete', opts)
        return request.user.has_perm("%s.%s" % (opts.app_label, codename)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:16,代码来源:options.py

示例13: _get_builtin_permissions

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def _get_builtin_permissions(opts):
    """
    Returns (codename, name) for all autogenerated permissions.
    By default, this is ('add', 'change', 'delete')
    """
    perms = []
    for action in opts.default_permissions:
        perms.append((get_permission_codename(action, opts),
            'Can %s %s' % (action, opts.verbose_name_raw)))
    return perms 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:12,代码来源:__init__.py

示例14: has_view_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_view_permission(self, request, obj=None):
        """
        Returns True if the given request has permission to view an object.
        Can be overridden by the user in subclasses.
        """
        opts = self.opts
        codename = get_permission_codename('view', opts)
        return request.user.has_perm("%s.%s" % (opts.app_label, codename)) 
开发者ID:ctxis,项目名称:django-admin-view-permission,代码行数:10,代码来源:admin.py

示例15: has_add_permission

# 需要导入模块: from django.contrib import auth [as 别名]
# 或者: from django.contrib.auth import get_permission_codename [as 别名]
def has_add_permission(self, request):
        """
        Return True if the given request has permission to add an object.
        Can be overridden by the user in subclasses.
        """
        opts = self.opts
        codename = get_permission_codename('add', opts)
        return request.user.has_perm("%s.%s" % (opts.app_label, codename)) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:10,代码来源:options.py


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