From e062f0b38a4e262d798a5b9b0794efc861c8aecd Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Mon, 6 Dec 2021 13:50:58 +0300 Subject: [PATCH 1/5] Added label ordering --- cvat/apps/engine/serializers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cvat/apps/engine/serializers.py b/cvat/apps/engine/serializers.py index b118f422c2af..1d85d54a5490 100644 --- a/cvat/apps/engine/serializers.py +++ b/cvat/apps/engine/serializers.py @@ -79,6 +79,7 @@ class LabelSerializer(serializers.ModelSerializer): class Meta: model = models.Label fields = ('id', 'name', 'color', 'attributes', 'deleted') + ordering = ['-id'] def validate(self, attrs): if attrs.get('deleted') == True and attrs.get('id') is None: From cfcd68d23d3654891a82267d8fdae42f2d957cdd Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Mon, 6 Dec 2021 13:57:52 +0300 Subject: [PATCH 2/5] Added CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f1b8f92d9c5..5d7ece9a4f74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed Interaction handler keyboard handlers () - Points of invisible shapes are visible in autobordering () - Order of the label attributes in the object item details() +- Order of label in tasks and projects () ### Security - TDB From 271f63a17d2acec9455f27659396852951066173 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Tue, 7 Dec 2021 11:36:34 +0300 Subject: [PATCH 3/5] Fixed ordering --- cvat/apps/engine/serializers.py | 1 - cvat/apps/engine/views.py | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cvat/apps/engine/serializers.py b/cvat/apps/engine/serializers.py index 1d85d54a5490..b118f422c2af 100644 --- a/cvat/apps/engine/serializers.py +++ b/cvat/apps/engine/serializers.py @@ -79,7 +79,6 @@ class LabelSerializer(serializers.ModelSerializer): class Meta: model = models.Label fields = ('id', 'name', 'color', 'attributes', 'deleted') - ordering = ['-id'] def validate(self, attrs): if attrs.get('deleted') == True and attrs.get('id') is None: diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index 935898ffa8dd..2639cb4c4592 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -234,7 +234,9 @@ class Meta: @method_decorator(name='destroy', decorator=swagger_auto_schema(operation_summary='Method deletes a specific project')) @method_decorator(name='partial_update', decorator=swagger_auto_schema(operation_summary='Methods does a partial update of chosen fields in a project')) class ProjectViewSet(auth.ProjectGetQuerySetMixin, viewsets.ModelViewSet): - queryset = models.Project.objects.all().order_by('-id') + queryset = models.Project.objects.prefetch_related(Prefetch('label_set', + queryset=models.Label.objects.order_by('id') + )) search_fields = ("name", "owner__username", "assignee__username", "status") filterset_class = ProjectFilter ordering_fields = ("id", "name", "owner", "status", "assignee") @@ -413,7 +415,8 @@ def get_filter_parameters(self, filter_backend): @method_decorator(name='destroy', decorator=swagger_auto_schema(operation_summary='Method deletes a specific task, all attached jobs, annotations, and data')) @method_decorator(name='partial_update', decorator=swagger_auto_schema(operation_summary='Methods does a partial update of chosen fields in a task')) class TaskViewSet(auth.TaskGetQuerySetMixin, viewsets.ModelViewSet): - queryset = Task.objects.all().prefetch_related( + queryset = Task.objects.prefetch_related( + Prefetch('label_set', queryset=models.Label.objects.order_by('id')), "label_set__attributespec_set", "segment_set__job_set", ).order_by('-id') From 37b8e8f10bc97549d20ac7645dcd7de08ed559df Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Tue, 7 Dec 2021 12:40:05 +0300 Subject: [PATCH 4/5] Fixed projects order --- cvat/apps/engine/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index 2639cb4c4592..e2a754616f3a 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -240,7 +240,8 @@ class ProjectViewSet(auth.ProjectGetQuerySetMixin, viewsets.ModelViewSet): search_fields = ("name", "owner__username", "assignee__username", "status") filterset_class = ProjectFilter ordering_fields = ("id", "name", "owner", "status", "assignee") - http_method_names = ['get', 'post', 'head', 'patch', 'delete'] + ordering = ("-id",) + http_method_names = ('get', 'post', 'head', 'patch', 'delete') def get_serializer_class(self): if self.request.path.endswith('tasks'): From 59e9df6b9ea8eb297afeb3eac02f356e8f89c2dd Mon Sep 17 00:00:00 2001 From: Nikita Manovich Date: Wed, 8 Dec 2021 23:04:34 +0300 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7ece9a4f74..5c94b4260a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed Interaction handler keyboard handlers () - Points of invisible shapes are visible in autobordering () - Order of the label attributes in the object item details() -- Order of label in tasks and projects () +- Order of labels in tasks and projects () ### Security - TDB