diff --git a/backend/api/filters.py b/backend/api/filters.py index 065bf581..c9e9dcf5 100644 --- a/backend/api/filters.py +++ b/backend/api/filters.py @@ -11,9 +11,11 @@ class DocumentFilter(FilterSet): speech2text_annotations__isnull = BooleanFilter(field_name='speech2text_annotations', method='filter_annotations') def filter_annotations(self, queryset, field_name, value): - queryset = queryset.annotate(num_annotations= - Count(field_name, filter= - Q(**{ f"{field_name}__user": self.request.user}) | Q(project__collaborative_annotation=True))) + queryset = queryset.annotate(num_annotations=Count( + expression=field_name, + filter=Q(**{f"{field_name}__user": self.request.user}) | Q(project__collaborative_annotation=True) + ) + ) should_have_annotations = not value if should_have_annotations: diff --git a/backend/api/serializers.py b/backend/api/serializers.py index f1ba2318..f26bb5d7 100644 --- a/backend/api/serializers.py +++ b/backend/api/serializers.py @@ -132,7 +132,8 @@ class ProjectSerializer(serializers.ModelSerializer): class Meta: model = Project fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', - 'updated_at', 'randomize_document_order', 'collaborative_annotation', 'single_class_classification', 'tags') + 'updated_at', 'randomize_document_order', 'collaborative_annotation', 'single_class_classification', + 'tags') read_only_fields = ('updated_at', 'users', 'current_users_role', 'tags') @@ -191,7 +192,6 @@ class ProjectFilteredPrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField): class DocumentAnnotationSerializer(serializers.ModelSerializer): - # label = ProjectFilteredPrimaryKeyRelatedField(queryset=Label.objects.all()) label = serializers.PrimaryKeyRelatedField(queryset=Label.objects.all()) document = serializers.PrimaryKeyRelatedField(queryset=Document.objects.all()) @@ -202,7 +202,6 @@ class DocumentAnnotationSerializer(serializers.ModelSerializer): class SequenceAnnotationSerializer(serializers.ModelSerializer): - #label = ProjectFilteredPrimaryKeyRelatedField(queryset=Label.objects.all()) label = serializers.PrimaryKeyRelatedField(queryset=Label.objects.all()) document = serializers.PrimaryKeyRelatedField(queryset=Document.objects.all()) diff --git a/backend/api/views/role.py b/backend/api/views/role.py index 43d1cf3a..ba91b42d 100644 --- a/backend/api/views/role.py +++ b/backend/api/views/role.py @@ -59,4 +59,3 @@ class RoleMappingDetail(generics.RetrieveUpdateAPIView): super().perform_update(serializer) except IntegrityError: raise RoleAlreadyAssignedException - diff --git a/backend/api/views/statistics.py b/backend/api/views/statistics.py index e9774029..0ffda23d 100644 --- a/backend/api/views/statistics.py +++ b/backend/api/views/statistics.py @@ -37,7 +37,7 @@ class StatisticsAPI(APIView): @staticmethod def _get_user_completion_data(annotation_class, annotation_filter): - all_annotation_objects = annotation_class.objects.filter(annotation_filter) + all_annotation_objects = annotation_class.objects.filter(annotation_filter) set_user_data = collections.defaultdict(set) for ind_obj in all_annotation_objects.values('user__username', 'document__id'): set_user_data[ind_obj['user__username']].add(ind_obj['document__id']) diff --git a/backend/api/views/upload/__init__.py b/backend/api/views/upload/__init__.py index 8b137891..e69de29b 100644 --- a/backend/api/views/upload/__init__.py +++ b/backend/api/views/upload/__init__.py @@ -1 +0,0 @@ - diff --git a/backend/api/views/upload/examples.py b/backend/api/views/upload/examples.py index 0a37a676..af7ebd97 100644 --- a/backend/api/views/upload/examples.py +++ b/backend/api/views/upload/examples.py @@ -61,7 +61,7 @@ Text_JSONL = """ """ Offset_JSONL = """ -{"column_data": "EU rejects German call to boycott British lamb.", "column_label": [ [0, 2, "ORG"], [11, 17, "MISC"], ... ]} +{"column_data": "EU rejects German call to boycott British lamb.", "column_label": [ [0, 2, "ORG"], ... ]} {"column_data": "Peter Blackburn", "column_label": [ [0, 15, "PERSON"] ]} {"column_data": "President Obama", "column_label": [ [10, 15, "PERSON"] ]} """ diff --git a/backend/api/views/user.py b/backend/api/views/user.py index a8379c74..d82187d7 100644 --- a/backend/api/views/user.py +++ b/backend/api/views/user.py @@ -24,4 +24,3 @@ class Users(generics.ListAPIView): pagination_class = None filter_backends = (DjangoFilterBackend, filters.SearchFilter) search_fields = ('username',) -