Browse Source

Change field name from randomized_document_order to random_order

pull/1370/head
Hironsan 3 years ago
parent
commit
2a02775071
5 changed files with 8 additions and 8 deletions
  1. 2
      backend/api/admin.py
  2. 2
      backend/api/models.py
  3. 8
      backend/api/serializers.py
  4. 2
      backend/api/views/document.py
  5. 2
      backend/api/views/image.py

2
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',)

2
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)

8
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')

2
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')

2
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')

Loading…
Cancel
Save