You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
434 B

2 years ago
  1. from rest_framework.permissions import BasePermission
  2. class CanEditLabel(BasePermission):
  3. def __init__(self, queryset):
  4. super().__init__()
  5. self.queryset = queryset
  6. def has_permission(self, request, view):
  7. if request.user.is_superuser:
  8. return True
  9. annotation_id = view.kwargs.get("annotation_id")
  10. return self.queryset.filter(id=annotation_id, user=request.user).exists()