當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。