コード例 #1
0
    def has_perm(self, perm, obj=None):
        #     "Does the user have a specific permission?"
        # Simplest possible answer: Yes, always

        if self.is_active and self.is_superuser:
            return True
        return _user_has_perm(self, perm, obj)
コード例 #2
0
ファイル: models.py プロジェクト: krish650/MicroSite
    def has_perm(self, perm, obj=None):
        # Active superusers have all permissions.
        if self.is_active and self.is_admin:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
コード例 #3
0
    def has_perm(self, perm, obj=None):
        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
コード例 #4
0
 def has_perm(self, perm, obj=None):
     """
     :param perm:
     :param obj:
     :return:
     """
     return _user_has_perm(self, perm, obj)
コード例 #5
0
ファイル: models.py プロジェクト: oogles/django-goodies
 def _check_perm(self, perm, obj):
     
     if not getattr(settings, 'DJEM_UNIVERSAL_OLP', False):
         # Default behaviour: active superusers implicitly have ALL permissions
         if self.is_active and self.is_superuser:
             return True, 'Active superuser: Implicit permission'
         
         return _user_has_perm(self, perm, obj), None
     else:
         # "Universal OLP" behaviour: active superusers implicitly have all
         # permissions at the model level, but are subject to object-level
         # checks
         if not obj and self.is_active and self.is_superuser:
             return True, 'Active superuser: Implicit permission (model-level)'
         
         return _user_has_perm(self, perm, obj), None
コード例 #6
0
    def has_perm(self, perm: Union[BasePermissionEnum, str], obj=None):  # type: ignore
        # This method is overridden to accept perm as BasePermissionEnum
        perm = perm.value if hasattr(perm, "value") else perm  # type: ignore

        # Active superusers have all permissions.
        if self.is_active and self.is_superuser and not self._effective_permissions:
            return True
        return _user_has_perm(self, perm, obj)
コード例 #7
0
ファイル: models.py プロジェクト: potatolondon/djangae
    def has_perm(self, perm, obj=None):
        from django.contrib.auth.models import _user_has_perm

        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
コード例 #8
0
 def has_perm(self, perm, obj=None):
     """
     Returns True if the user has the specified permission. This method
     queries all available auth backends, but returns immediately if any
     backend returns True. Thus, a user who has permission from a single
     auth backend is assumed to have permission in general. If an object is
     provided, permissions for this specific object are checked.
     """
     return _user_has_perm(self, perm, obj)
コード例 #9
0
 def has_perm(self, perm, obj=None):
     "Does the user have a specific permission?"
     # Simplest possible answer: Yes, always
     # print('user perm:',perm)
     if not self.is_active:
         return False
     if self.is_admin:
         return True
     return _user_has_perm(self, perm, obj)
コード例 #10
0
ファイル: models.py プロジェクト: Cocktail-Hunter/django
    def has_perm(self, perm, obj=None):
        '''
        Checks if the user has a specific permission
        '''
        # Active admins have all permissions
        if self.is_active and self.is_admin:
            return True

        # Otherwise we need to check the backends
        return _user_has_perm(self, perm, obj)
コード例 #11
0
ファイル: models.py プロジェクト: NotYours180/kolibri
    def has_perm(self, perm, obj=None):
        """
        Checks whether a user has the given permission.

        :param perm: A string identifying the permission. See the backends module in this app for a complete list.
        :param obj: An optional object, the interpretation of which depends on the permission string.
        :return: True or False
        :raises: ``InvalidPermission`` if the given permission string is unknown, or if the optional ``obj`` is an
            unexpected type.
        """
        return _user_has_perm(self, perm, obj)
コード例 #12
0
    def has_perm(self, perm, obj=None):
        """
        Override PermissionsMixin has_perm to deactivate is_superuser if
        authenticated through a token
        """

        # Active superusers have all permissions.
        if self.is_active and self.is_superuser and not hasattr(self, "token"):
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
コード例 #13
0
    def has_perm(self, perm, obj=None):
        """Return True if the reviewer has the specified permission. Query all
        available auth backends, but return immediately if any backend returns
        True. Thus, a reviewer who has permission from a single auth backend is
        assumed to have permission in general. If an object is provided, check
        permissions for that object.
        """
        # Active superusers have all permissions.
        if self.is_active and self.trusted:
            return True

        # Otherwise we need to check the backends.
        return auth_models._user_has_perm(self, perm, obj)
コード例 #14
0
ファイル: models.py プロジェクト: sythaeryn/django-orchestra
 def has_perm(self, perm, obj=None):
     """
     Returns True if the user has the specified permission. This method
     queries all available auth backends, but returns immediately if any
     backend returns True. Thus, a user who has permission from a single
     auth backend is assumed to have permission in general. If an object is
     provided, permissions for this specific object are checked.
     """
     # Active superusers have all permissions.
     if self.is_active and self.is_superuser:
         return True
     # Otherwise we need to check the backends.
     return auth._user_has_perm(self, perm, obj)
コード例 #15
0
ファイル: auth.py プロジェクト: cjrh/gcloud-datastore-oem
    def has_perm(self, perm, obj=None):
        """
        Returns True if the user has the specified permission. This method queries all available auth backends, but
        returns immediately if any backend returns True. Thus, a user who has permission from a single auth backend is
        assumed to have permission in general. If an object is provided, permissions for this specific object are
        checked.
        """
        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
コード例 #16
0
    def has_perm(self, perm, obj=None):
        """
        Returns True if the user has the specified permission. This method
        queries all available auth backends, but returns immediately if any
        backend returns True. Thus, a user who has permission from a single
        auth backend is assumed to have permission in general. If an object is
        provided, permissions for this specific object are checked.

        This differs from the default in that superusers, while still having
        every permission, will be allowed after the logic has executed. This
        helps with typos in permission strings.
        """
        has_perm = _user_has_perm(self, perm, obj)
        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True
        else:
            return has_perm
コード例 #17
0
ファイル: models.py プロジェクト: Evans-Notch/lnldb
    def has_perm(self, perm, obj=None):
        """
        Returns True if the user has the specified permission. This method
        queries all available auth backends, but returns immediately if any
        backend returns True. Thus, a user who has permission from a single
        auth backend is assumed to have permission in general. If an object is
        provided, permissions for this specific object are checked.

        This differs from the default in that superusers, while still having
        every permission, will be allowed after the logic has executed. This
        helps with typos in permission strings.
        """
        has_perm = _user_has_perm(self, perm, obj)
        # Active superusers have all permissions.
        if self.is_active and self.is_superuser:
            return True
        else:
            return has_perm
コード例 #18
0
ファイル: user.py プロジェクト: Fatou1993/chocapix-server
    def has_perm(self, perm, obj=None):
        if self.is_active and self.is_superuser:
            return True

        return _user_has_perm(self, perm, obj)
コード例 #19
0
 def has_terra_perm(self, codename):
     return _user_has_perm(self, f'{self._meta.app_label}.{codename}', None)
コード例 #20
0
 def user_has_perm(user, perm, obj):
     """
     A backend can raise `PermissionDenied` to short-circuit permission checking.
     """
     return _user_has_perm(user, perm, obj)
コード例 #21
0
ファイル: models.py プロジェクト: flipjack/zaresdelweb_blog
 def has_perm(self, perm, obj=None):
     if self.is_superuser and self.activo:
         return True
     return _user_has_perm(self, perm, obj=obj)
コード例 #22
0
 def user_has_perm(self, perm, obj):
     return _user_has_perm(self, perm, obj)
コード例 #23
0
ファイル: models.py プロジェクト: Uttah/syn_app
 def has_perm(self, perm, obj=None):
     # Не уволенные суперпользователи имеют весь доступ
     if not self.fired and self.is_superuser:
         return True
     return _user_has_perm(self, perm, obj)
コード例 #24
0
 def has_perm(self, perm, obj=None):
     return auth_models._user_has_perm(self, perm, obj=obj)
コード例 #25
0
 def has_perm(self, perm, obj=None):
     """Near complete coppy of the django.auth.contrib.models.User has_perm method."""
     return _user_has_perm(self, perm, None)
コード例 #26
0
 def has_perm(self, perm, obj=None):
     """Near complete coppy of the django.auth.contrib.models.User has_perm method."""
     return _user_has_perm(self, perm, None)
コード例 #27
0
ファイル: models.py プロジェクト: suesan/uknow
 def user_has_perm(user, perm, obj):
     """
     A backend can raise `PermissionDenied` to short-circuit permission checking.
     """
     return _user_has_perm(user, perm, obj)
コード例 #28
0
ファイル: models.py プロジェクト: danjac/ownblock
 def has_perm(self, perm, obj=None):
     return _user_has_perm(self, perm, obj=obj)
コード例 #29
0
 def user_has_perm(user, perm, obj):
     return _user_has_perm(user, perm, obj)
コード例 #30
0
 def has_perm(self, perm, obj=None):
     return _user_has_perm(self, perm, obj=obj)
コード例 #31
0
 def has_edit_perm(self, perm, obj=None):
     if self.pk == obj.pk:
         return True
     return auth_models._user_has_perm(self, perm, obj)
コード例 #32
0
    def has_perm(self, perm, obj=None):
        if self.is_active and self.is_superuser:
            return True

        # Otherwise we need to check the backends.
        return _user_has_perm(self, perm, obj)
コード例 #33
0
ファイル: models.py プロジェクト: darjeeling/k-board
    def has_perm(self, perm, obj=None):
        if self.is_active and self.is_superuser:
            return True

        return auth_models._user_has_perm(self, perm, obj)