Bases: DatasetNestedViewSet
Dataset permissions.
Source code in src/apps/core/views/permissions_view.py
| class DatasetPermissionsViewSet(DatasetNestedViewSet):
"""Dataset permissions."""
http_method_names = ["get", "options"]
serializer_class = DatasetPermissionsSerializer
access_policy = DatasetPermissionsAccessPolicy
def get_queryset(self):
if getattr(
self, "swagger_fake_view", None
): # kwargs are not available in swagger inspection
return self.serializer_class.Meta.model.available_objects.none()
dataset = self.get_dataset_instance()
return self.serializer_class.Meta.model.all_objects.filter(datasets=dataset)
def get_object(self):
queryset = self.get_queryset()
permissions: DatasetPermissions = get_object_or_404(queryset)
self.check_object_permissions(self.request, permissions)
dataset = self.get_dataset_instance()
permissions.set_context_dataset(dataset)
return permissions
|