From 2a027750714ffd275c3e6f95b094329a6c3190c0 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 12 May 2021 14:44:39 +0900 Subject: [PATCH] Change field name from randomized_document_order to random_order --- backend/api/admin.py | 2 +- backend/api/models.py | 2 +- backend/api/serializers.py | 8 ++++---- backend/api/views/document.py | 2 +- backend/api/views/image.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/api/admin.py b/backend/api/admin.py index 00ff8b64..22297bde 100644 --- a/backend/api/admin.py +++ b/backend/api/admin.py @@ -19,7 +19,7 @@ class DocumentAdmin(admin.ModelAdmin): class ProjectAdmin(admin.ModelAdmin): - list_display = ('name', 'description', 'project_type', 'randomize_document_order', 'collaborative_annotation') + list_display = ('name', 'description', 'project_type', 'random_order', 'collaborative_annotation') ordering = ('project_type',) search_fields = ('name',) diff --git a/backend/api/models.py b/backend/api/models.py index 14b1c72c..7de3a3df 100644 --- a/backend/api/models.py +++ b/backend/api/models.py @@ -29,7 +29,7 @@ class Project(PolymorphicModel): updated_at = models.DateTimeField(auto_now=True) users = models.ManyToManyField(User, related_name='projects') project_type = models.CharField(max_length=30, choices=PROJECT_CHOICES) - randomize_document_order = models.BooleanField(default=False) + random_order = models.BooleanField(default=False) collaborative_annotation = models.BooleanField(default=False) single_class_classification = models.BooleanField(default=False) diff --git a/backend/api/serializers.py b/backend/api/serializers.py index c67ce685..0152e5b1 100644 --- a/backend/api/serializers.py +++ b/backend/api/serializers.py @@ -8,12 +8,12 @@ from rest_polymorphic.serializers import PolymorphicSerializer from .models import (DOCUMENT_CLASSIFICATION, SEQ2SEQ, SEQUENCE_LABELING, SPEECH2TEXT, AutoLabelingConfig, Comment, Document, - DocumentAnnotation, Image, ImageCategoryLabel, + DocumentAnnotation, Example, Image, ImageCategoryLabel, ImageClassificationProject, Label, Project, Role, RoleMapping, Seq2seqAnnotation, Seq2seqProject, SequenceAnnotation, SequenceLabelingProject, Speech2textAnnotation, Speech2textProject, Tag, - TextClassificationProject, Example) + TextClassificationProject) class UserSerializer(serializers.ModelSerializer): @@ -157,7 +157,7 @@ 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', + 'updated_at', 'random_order', 'collaborative_annotation', 'single_class_classification', 'tags') read_only_fields = ('updated_at', 'users', 'current_users_role', 'tags') @@ -191,7 +191,7 @@ class Speech2textProjectSerializer(ProjectSerializer): class Meta: model = Speech2textProject fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', - 'updated_at', 'randomize_document_order') + 'updated_at', 'random_order') read_only_fields = ('updated_at', 'users', 'current_users_role') diff --git a/backend/api/views/document.py b/backend/api/views/document.py index 270da3a9..c46033bd 100644 --- a/backend/api/views/document.py +++ b/backend/api/views/document.py @@ -27,7 +27,7 @@ class DocumentList(generics.ListCreateAPIView): queryset = project.examples.instance_of(Document) queryset.model = Document - if project.randomize_document_order: + if project.random_order: random.seed(self.request.user.id) value = random.randrange(2, 20) queryset = queryset.annotate(sort_id=F('id') % value).order_by('sort_id', 'id') diff --git a/backend/api/views/image.py b/backend/api/views/image.py index fe2fceac..1b479f48 100644 --- a/backend/api/views/image.py +++ b/backend/api/views/image.py @@ -23,7 +23,7 @@ class ImageList(generics.ListCreateAPIView): project = get_object_or_404(Project, pk=self.kwargs['project_id']) queryset = project.examples - if project.randomize_document_order: + if project.random_order: random.seed(self.request.user.id) value = random.randrange(2, 20) queryset = queryset.annotate(sort_id=F('id') % value).order_by('sort_id', 'id')