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


Python compat.is_authenticated方法代码示例

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


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

示例1: has_permission

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def has_permission(self, request, view):
        """
        List/create objects permission.

        :param request: django request instance.
        :type request: django.http.request.HttpRequest.
        :param view: view set.
        :type view: mk42.apps.core.api.viewsets.rsvp.RSVPViewset.
        :return: permission is granted.
        :rtype: bool.
        """

        if request.method in SAFE_METHODS:
            # Read permissions are allowed to any request, so we'll always allow GET, HEAD or OPTIONS requests.
            return True

        if all([request.method == POST, is_authenticated(request.user), ]):
            # Allow join to event only for authenticated users.
            return True

        if request.method == DELETE:
            # In futures steps of flow allow user delete own RSVP.
            return True 
开发者ID:Peer-Lab,项目名称:mk42,代码行数:25,代码来源:rsvp.py

示例2: has_permission

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def has_permission(self, request, view):
        """
        List/create objects permission.

        :param request: django request instance.
        :type request: django.http.request.HttpRequest.
        :param view: view set.
        :type view: mk42.apps.core.api.viewsets.event_log.EventLogViewset.
        :return: permission is granted.
        :rtype: bool.
        """

        if request.method in SAFE_METHODS:
            # Read permissions are allowed to any request, so we'll always allow GET, HEAD or OPTIONS requests.
            return True

        if all([request.method == POST, is_authenticated(request.user), self.check_event_owner(request)]):
            # Allow add new status only for authenticated users.
            return True

        if request.method == PATCH:
            # In futures steps of flow allow user edit self owned events.
            return False 
开发者ID:Peer-Lab,项目名称:mk42,代码行数:25,代码来源:log.py

示例3: has_permission

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def has_permission(self, request, view):
        """
        List/create objects permission.

        :param request: django request instance.
        :type request: django.http.request.HttpRequest.
        :param view: view set.
        :type view: mk42.apps.core.api.viewsets.group.GroupViewset.
        :return: permission is granted.
        :rtype: bool.
        """

        if request.method in SAFE_METHODS:
            # Read permissions are allowed to any request, so we'll always allow GET, HEAD or OPTIONS requests.
            return True

        if all([request.method == POST, is_authenticated(request.user), ]):
            # Allow create groups only for authenticated users.
            return True

        if all([request.method == PATCH, is_authenticated(request.user), ]):
            # In futures steps of flow allow user edit self owned groups.
            return True 
开发者ID:Peer-Lab,项目名称:mk42,代码行数:25,代码来源:group.py

示例4: get_cache_key

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def get_cache_key(self, request, view):
        """
        If `view.throttle_scope` is not set, don't apply this throttle.

        Otherwise generate the unique cache key by concatenating the user id
        with the '.throttle_scope` property of the view.
        """
        if is_authenticated(request.user):
            ident = request.user.pk
        else:
            ident = self.get_ident(request)

        return self.cache_format % {
            'scope': self.scope,
            'ident': ident
        } 
开发者ID:Lurance,项目名称:sdining,代码行数:18,代码来源:throttling.py

示例5: has_permission

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def has_permission(self, request, view):
        """
        List/create objects permission.

        :param request: django request instance.
        :type request: django.http.request.HttpRequest.
        :param view: view set.
        :type view: mk42.apps.core.api.viewsets.event.EventViewset.
        :return: permission is granted.
        :rtype: bool.
        """

        if request.method in SAFE_METHODS:
            # Read permissions are allowed to any request, so we'll always allow GET, HEAD or OPTIONS requests.
            return True
  
        if all([request.method == POST, is_authenticated(request.user), ]):
            # Allow create events only for authenticated users.
            if not self.check_event_dates(request):
                self.message = _("Invalid dates.")

                return False
                
            return True

        if request.method == PATCH:
            # In futures steps of flow allow user edit self owned events.
            return True 
开发者ID:Peer-Lab,项目名称:mk42,代码行数:30,代码来源:event.py

示例6: has_permission

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def has_permission(self, request, view):
        """
        List/create objects permission.

        :param request: django request instance.
        :type request: django.http.request.HttpRequest.
        :param view: view set.
        :type view: mk42.apps.core.api.viewsets.membership.MembershipViewset.
        :return: permission is granted.
        :rtype: bool.
        """

        if request.method in SAFE_METHODS:
            # Read permissions are allowed to any request, so we'll always allow GET, HEAD or OPTIONS requests.
            return True

        if all([request.method == POST, is_authenticated(request.user), ]):
            # Allow join to groups only for authenticated users.
            return True

        if all([request.method == DELETE, is_authenticated(request.user), ]):
            # In futures steps of flow allow user delete own membership.
            return True

        if all([request.method == PATCH, is_authenticated(request.user), ]):
            # In futures steps of flow allow owner of group to activate membership
            return True 
开发者ID:Peer-Lab,项目名称:mk42,代码行数:29,代码来源:membership.py

示例7: has_permission

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def has_permission(self, request, view):
        return request.user and is_authenticated(request.user) 
开发者ID:Lurance,项目名称:sdining,代码行数:4,代码来源:permissions.py

示例8: get_configuration

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def get_configuration(self):
        request = self.context.get("request", None)
        if request and is_authenticated(request.user):
            return NotificationBase.get_mapped_user_notifications_types_and_categories(request.user)
        return None 
开发者ID:ArabellaTech,项目名称:universal_notifications,代码行数:7,代码来源:serializers.py

示例9: get

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def get(self, request, *args, **kwargs):
        if request.user and is_authenticated(request.user):
            print request.user.profile
            userPro = request.user.profile
            serializer = self.get_serializer(userPro)
            return Response(serializer.data)
        return Response("") 
开发者ID:youjiajia,项目名称:pigroom,代码行数:9,代码来源:views.py

示例10: has_object_permission

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def has_object_permission(self, request, view, obj):
        if request.method in ('CREATE',):
            return True
        if request.user and is_authenticated(request.user):
            return True
        return False 
开发者ID:youjiajia,项目名称:pigroom,代码行数:8,代码来源:__init__.py

示例11: has_permission

# 需要导入模块: from rest_framework import compat [as 别名]
# 或者: from rest_framework.compat import is_authenticated [as 别名]
def has_permission(self, request, view):
		if view.action == "create" and request.user and is_authenticated(request.user):
			return True
		elif view.action == "list" and request.user and request.user.is_superuser:
			return True
		return False 
开发者ID:pmontu,项目名称:indian_farming,代码行数:8,代码来源:permissions.py


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