|
|
|
|
@ -308,9 +308,10 @@ class ProjectViewSet(viewsets.GenericViewSet, mixins.ListModelMixin,
|
|
|
|
|
mixins.RetrieveModelMixin, CreateModelMixin, DestroyModelMixin,
|
|
|
|
|
PartialUpdateModelMixin, UploadMixin, AnnotationMixin, SerializeMixin
|
|
|
|
|
):
|
|
|
|
|
queryset = models.Project.objects.prefetch_related(Prefetch('label_set',
|
|
|
|
|
queryset=models.Label.objects.order_by('id')
|
|
|
|
|
))
|
|
|
|
|
queryset = models.Project.objects.select_related('assignee', 'owner',
|
|
|
|
|
'target_storage', 'source_storage').prefetch_related(
|
|
|
|
|
'tasks', 'label_set__sublabels__attributespec_set',
|
|
|
|
|
'label_set__attributespec_set')
|
|
|
|
|
|
|
|
|
|
# NOTE: The search_fields attribute should be a list of names of text
|
|
|
|
|
# type fields on the model,such as CharField or TextField
|
|
|
|
|
@ -752,10 +753,12 @@ class TaskViewSet(viewsets.GenericViewSet, mixins.ListModelMixin,
|
|
|
|
|
mixins.RetrieveModelMixin, CreateModelMixin, DestroyModelMixin,
|
|
|
|
|
PartialUpdateModelMixin, UploadMixin, AnnotationMixin, SerializeMixin
|
|
|
|
|
):
|
|
|
|
|
queryset = Task.objects.prefetch_related(
|
|
|
|
|
Prefetch('label_set', queryset=models.Label.objects.order_by('id')),
|
|
|
|
|
"label_set__attributespec_set",
|
|
|
|
|
"segment_set__job_set")
|
|
|
|
|
queryset = Task.objects.all().select_related('data', 'assignee', 'owner',
|
|
|
|
|
'target_storage', 'source_storage').prefetch_related(
|
|
|
|
|
'segment_set__job_set__assignee', 'label_set__attributespec_set',
|
|
|
|
|
'project__label_set__attributespec_set',
|
|
|
|
|
'label_set__sublabels__attributespec_set',
|
|
|
|
|
'project__label_set__sublabels__attributespec_set')
|
|
|
|
|
lookup_fields = {'project_name': 'project__name', 'owner': 'owner__username', 'assignee': 'assignee__username'}
|
|
|
|
|
search_fields = ('project_name', 'name', 'owner', 'status', 'assignee', 'subset', 'mode', 'dimension')
|
|
|
|
|
filter_fields = list(search_fields) + ['id', 'project_id', 'updated_date']
|
|
|
|
|
@ -1318,10 +1321,16 @@ class TaskViewSet(viewsets.GenericViewSet, mixins.ListModelMixin,
|
|
|
|
|
'200': JobReadSerializer, # check JobWriteSerializer.to_representation
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
class JobViewSet(viewsets.GenericViewSet, mixins.ListModelMixin,
|
|
|
|
|
mixins.RetrieveModelMixin, PartialUpdateModelMixin, UploadMixin, AnnotationMixin
|
|
|
|
|
):
|
|
|
|
|
queryset = Job.objects.all()
|
|
|
|
|
queryset = Job.objects.all().select_related('segment__task__data').prefetch_related(
|
|
|
|
|
'segment__task__label_set', 'segment__task__project__label_set',
|
|
|
|
|
'segment__task__label_set__sublabels__attributespec_set',
|
|
|
|
|
'segment__task__project__label_set__sublabels__attributespec_set',
|
|
|
|
|
'segment__task__label_set__attributespec_set',
|
|
|
|
|
'segment__task__project__label_set__attributespec_set')
|
|
|
|
|
iam_organization_field = 'segment__task__organization'
|
|
|
|
|
search_fields = ('task_name', 'project_name', 'assignee', 'state', 'stage')
|
|
|
|
|
filter_fields = list(search_fields) + ['id', 'task_id', 'project_id', 'updated_date']
|
|
|
|
|
|