def retrieve(self, request, *args, **kwargs): data = serializers.CurrentUserSerializer({ 'is_partner_engineer': permissions.IsPartnerEngineer().has_permission(request, self) }).data return Response(data)
def get_permissions(self): permission_list = super().get_permissions() if self.request.method == 'POST': permission_list.append(permissions.IsPartnerEngineer()) elif self.request.method == 'PUT': permission_list.append( permissions.IsNamespaceOwnerOrPartnerEngineer()) return permission_list
def get_queryset(self): """ Returns all namespaces for users in the partner-engineers group, otherwise returns namespaces with groups the user belongs to. """ if permissions.IsPartnerEngineer().has_permission(self.request, self): return models.Namespace.objects.all() else: return models.Namespace.objects.filter( groups__in=self.request.user.groups.all())
def get_queryset(self): # All namespaces for users in the partner-engineers groups if permissions.IsPartnerEngineer().has_permission(self.request, self): queryset = models.Namespace.objects.all() return queryset # Just the namespaces with groups the user is in queryset = models.Namespace.objects.filter( groups__in=self.request.user.groups.all()) return queryset
def get_queryset(self): """ Returns all synclists for the user. """ log.debug('self.request.user: %s', self.request.user) if permissions.IsPartnerEngineer().has_permission(self.request, self): log.debug('Viewing mysynclist as partner user=%s, groups=%s', self.request.user, self.request.user.groups) return models.SyncList.objects.all() else: log.debug('Viewing mysynclist as user=%s with groups=%s', self.request.user, self.request.user.groups) return models.SyncList.objects.filter( groups__in=self.request.user.groups.all())
def get_permissions(self): return super().get_permissions() + [ permissions.IsPartnerEngineer(), permissions.RestrictOnCloudDeployments() ]
def get_permissions(self): return super().get_permissions() + \ [permissions.IsPartnerEngineer(), permissions.RestrictOnStandaloneDeployments()]