Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • arkindex/backend
1 result
Show changes
Commits on Source (2)
1.6.1-beta3
1.6.1-rc1
......@@ -573,14 +573,12 @@ class ElementsListBase(CorpusACLMixin, DestroyModelMixin, ListAPIView):
@cached_property
def selected_corpus(self):
# Retrieve the corpus and check user access rights only once
# Retrieve the corpus only once
corpus_id = self.kwargs.get("corpus")
if corpus_id is None:
return
corpus = get_object_or_404(Corpus, id=corpus_id)
self.check_corpus_access(corpus)
return corpus
return get_object_or_404(Corpus, id=corpus_id)
@property
def folder_filter(self):
......@@ -1041,6 +1039,7 @@ class CorpusElements(ElementsListBase):
def get_queryset(self):
# Should not be possible due to the URL
assert self.selected_corpus, "Missing corpus ID"
self.check_corpus_access(self.selected_corpus)
return self.selected_corpus.elements.all()
def get_filters(self) -> Q:
......
......@@ -6,7 +6,7 @@ from django.shortcuts import get_object_or_404
from django.utils import timezone
from django.utils.functional import cached_property
from drf_spectacular.utils import extend_schema, extend_schema_view
from rest_framework import permissions, serializers, status
from rest_framework import permissions, status
from rest_framework.exceptions import PermissionDenied, ValidationError
from rest_framework.generics import ListCreateAPIView, RetrieveDestroyAPIView
from rest_framework.response import Response
......@@ -78,7 +78,7 @@ class CorpusExportAPIView(ListCreateAPIView):
Guest access is required on private corpora.
"""
),
responses={302: serializers.Serializer},
responses={302: None},
),
delete=extend_schema(
operation_id="DestroyExport",
......
......@@ -4,7 +4,7 @@ from textwrap import dedent
from django.db import transaction
from django.shortcuts import get_object_or_404, redirect
from drf_spectacular.utils import extend_schema, extend_schema_view
from rest_framework import serializers, status
from rest_framework import status
from rest_framework.authentication import SessionAuthentication, TokenAuthentication
from rest_framework.exceptions import NotFound, ValidationError
from rest_framework.generics import CreateAPIView, ListCreateAPIView, RetrieveUpdateAPIView, UpdateAPIView
......@@ -200,12 +200,12 @@ class TaskUpdate(UpdateAPIView):
The task must be in a final state to be restarted.
"""
),
request=None,
responses={201: TaskSerializer},
),
)
class TaskRestart(ProcessACLMixin, CreateAPIView):
permission_classes = (IsVerified,)
serializer_class = serializers.Serializer
def get_task(self):
task = get_object_or_404(
......
......@@ -1327,7 +1327,7 @@ class WorkerRunList(ProcessACLMixin, ListCreateAPIView):
201: WorkerRunSerializer,
400: OpenApiResponse(
response=inline_serializer(
name="Error message with ID",
name="ErrorWithID",
fields={
"detail": serializers.ListField(child=serializers.CharField(), required=False),
"id": serializers.UUIDField(required=False, help_text="ID of an existing worker run")
......@@ -1557,6 +1557,7 @@ class WorkerRunDetails(ProcessACLMixin, RetrieveUpdateDestroyAPIView):
False: ProcessElementLightSerializer,
},
resource_type_field_name="with_image",
many=True,
),
tags=["process"]
))
......@@ -2193,6 +2194,7 @@ class S3ImportCreate(CreateAPIView):
post=extend_schema(
operation_id="SelectProcessFailures",
tags=["process"],
request=None,
responses={204: None},
),
)
......
......@@ -3049,18 +3049,21 @@ class TestProcesses(FixtureAPITestCase):
self.elts_process.activity_state = ActivityState.Ready
self.elts_process.save()
self.client.force_login(self.user)
for state in unfinished_states:
with self.subTest(state=state):
self.elts_process.tasks.update(state=state)
self.assertEqual(self.elts_process.state, state)
response = self.client.post(
reverse("api:process-select-failures", kwargs={"pk": str(self.elts_process.id)})
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertDictEqual(
response.json(),
{"__all__": ["The process must be finished to select elements with failures."]},
)
self.assertDictEqual(
response.json(),
{"__all__": ["The process must be finished to select elements with failures."]},
)
def test_select_failed_elts_no_failure(self):
self.elts_process.run()
......
......@@ -32,5 +32,6 @@ class AutoSchema(BaseAutoSchema):
Spectacular does not include any pagination parameters.
"""
operation = super().get_operation(*args, **kwargs)
operation["x-paginated"] = self._is_list_view() and self._get_paginator() is not None
if operation is not None:
operation["x-paginated"] = self._is_list_view() and self._get_paginator() is not None
return operation
......@@ -219,6 +219,9 @@ SIMPLE_JWT = {
SPECTACULAR_SETTINGS = {
"CAMELIZE_NAMES": True,
# Remove the automatically generated `description` that lists the members of all enums,
# which duplicates the enum choices already displayed by ReDoc and does not add any documentation
"ENUM_GENERATE_CHOICE_DESCRIPTION": False,
"SCHEMA_PATH_PREFIX": "/api/v1/",
"TITLE": "Arkindex API",
"CONTACT": {
......
......@@ -522,9 +522,7 @@ class ModelCompatibleWorkerManage(CreateAPIView, DestroyAPIView):
"Retrieve a download url for a model_version. A secret token is required to have access to the model version."
"This endpoint does **not** require to be logged in."
),
responses={
302: serializers.Serializer,
},
responses={302: None},
parameters=[
OpenApiParameter(
"token",
......
......@@ -171,7 +171,7 @@ class ModelVersionLightSerializer(serializers.ModelSerializer):
model = ModelLightSerializer(default=_model_from_context)
state = EnumField(ModelVersionState)
configuration = serializers.JSONField(style={"base_template": "textarea.html"})
configuration = serializers.DictField(style={"base_template": "textarea.html"})
class Meta:
model = ModelVersion
......@@ -190,7 +190,7 @@ class ModelVersionSerializer(serializers.ModelSerializer):
allow_null=True,
)
description = serializers.CharField(required=False, style={"base_template": "textarea.html"})
configuration = serializers.JSONField(required=False, decoder=None, encoder=None, style={"base_template": "textarea.html"})
configuration = serializers.DictField(required=False, style={"base_template": "textarea.html"})
tag = serializers.CharField(allow_null=True, max_length=50, required=False, default=None)
state = EnumField(ModelVersionState, read_only=True)
s3_url = serializers.SerializerMethodField(read_only=True, help_text="Only returned if the user has **contributor** access to the model, and the model is available.")
......
......@@ -13,7 +13,7 @@ from django_rq.queues import get_queue
from django_rq.settings import QUEUES
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, extend_schema, extend_schema_view
from rest_framework import serializers, status
from rest_framework import status
from rest_framework.exceptions import AuthenticationFailed, NotFound, PermissionDenied, ValidationError
from rest_framework.generics import CreateAPIView, ListAPIView, RetrieveDestroyAPIView, RetrieveUpdateDestroyAPIView
from rest_framework.response import Response
......@@ -180,7 +180,7 @@ class UserEmailVerification(APIView):
required=True,
)
],
responses={302: serializers.Serializer}
responses={302: None},
)
def get(self, *args, **kwargs):
if not all(arg in self.request.GET for arg in ("email", "token")):
......
......@@ -161,9 +161,7 @@ class JobSerializer(serializers.Serializer):
ended_at = serializers.DateTimeField(read_only=True, allow_null=True)
def get_status(self, instance) -> str:
"""
Avoid causing more Redis queries to fetch a job's current status
Note that a job status is part of a JobStatus enum,
but the enum is just a plain object and not an Enum for Py2 compatibility.
"""
# Avoid causing more Redis queries to fetch a job's current status
# Note that a job status is part of a JobStatus enum,
# but the enum is just a plain object and not an Enum for Py2 compatibility.
return instance.get_status(refresh=False)
......@@ -10,7 +10,7 @@ django-rq==2.10.1
djangorestframework==3.13.1
djangorestframework-simplejwt==5.2.2
docker==7.0.0
drf-spectacular==0.21.2
drf-spectacular==0.27.2
python-magic==0.4.27
python-memcached==1.59
pytz==2023.3
......