Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OPTIC-630: Restrict access to project import UI and API through a billing flag #5808

Merged
merged 9 commits into from
May 6, 2024
Prev Previous commit
Next Next commit
adding tests and restricting more of the import apis
  • Loading branch information
bmartel committed Apr 30, 2024
commit 4ff32c9dfbb1a1782dc609c12b5d38a282fc1452
6 changes: 6 additions & 0 deletions label_studio/data_import/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@
from rest_framework.parsers import FormParser, JSONParser, MultiPartParser
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.settings import api_settings
from rest_framework.views import APIView
from tasks.functions import update_tasks_counters
from tasks.models import Prediction, Task
from users.models import User
from webhooks.models import WebhookAction
from webhooks.utils import emit_webhooks_for_instance

from label_studio.core.utils.common import load_func

from .functions import (
async_import_background,
async_reimport_background,
Expand All @@ -49,6 +52,8 @@

logger = logging.getLogger(__name__)

ProjectImportPermission = load_func(settings.PROJECT_IMPORT_PERMISSION)


task_create_response_scheme = {
201: openapi.Response(
Expand Down Expand Up @@ -175,6 +180,7 @@
# Import
class ImportAPI(generics.CreateAPIView):
permission_required = all_permissions.projects_change
permission_classes = api_settings.DEFAULT_PERMISSION_CLASSES + [ProjectImportPermission]
parser_classes = (JSONParser, MultiPartParser, FormParser)
serializer_class = ImportApiSerializer
queryset = Task.objects.all()
Expand Down
Loading