jumpserver/apps/ops/api/base.py

18 lines
514 B
Python
Raw Normal View History

2022-12-06 09:30:54 +00:00
from rest_framework_bulk import BulkModelViewSet
from common.mixins import CommonApiMixin
__all__ = ['SelfBulkModelViewSet']
class SelfBulkModelViewSet(CommonApiMixin, BulkModelViewSet):
def get_queryset(self):
if hasattr(self, 'model'):
return self.model.objects.filter(creator=self.request.user)
else:
assert self.queryset is None, (
"'%s' should not include a `queryset` attribute"
% self.__class__.__name__
)