INNER CODE UNIT · Python

in_groups

Patrowl/PatrowlManager · common/utils/__init__.py:24

    def in_groups(u):
        from django.conf import settings
        if not settings.PRO_EDITION or u.is_superuser:
            return True
        if u.is_authenticated:
            if bool(u.groups.filter(name__in=group_names)):
                return True
        return False
    return user_passes_test(in_groups)


def get_api_default_permissions(self):
    from rest_framework.decorators import permission_classes
    from rest_framework.permissions import IsAdminUser, IsAuthenticated
    if self.action == 'list':
        permission_classes = [IsAuthenticated]
    else:
        permission_classes = [IsAdminUser]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…