diff --git a/backend/label_types/migrations/0002_rename_relationtypes_relationtype.py b/backend/label_types/migrations/0002_rename_relationtypes_relationtype.py new file mode 100644 index 00000000..561f6d7e --- /dev/null +++ b/backend/label_types/migrations/0002_rename_relationtypes_relationtype.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.11 on 2022-01-27 07:27 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('labels', '0003_auto_20220127_0654'), + ('api', '0033_auto_20220127_0654'), + ('label_types', '0001_initial'), + ] + + operations = [ + migrations.RenameModel( + old_name='RelationTypes', + new_name='RelationType', + ), + ] diff --git a/backend/label_types/models.py b/backend/label_types/models.py index a25a9509..b340f34b 100644 --- a/backend/label_types/models.py +++ b/backend/label_types/models.py @@ -88,7 +88,7 @@ class SpanType(LabelType): return SpanType.objects.filter(project=self.project) -class RelationTypes(models.Model): +class RelationType(models.Model): color = models.TextField() name = models.TextField() project = models.ForeignKey(Project, related_name='relation_types', on_delete=models.CASCADE) diff --git a/backend/label_types/serializers.py b/backend/label_types/serializers.py index cc8c3126..5e1368a4 100644 --- a/backend/label_types/serializers.py +++ b/backend/label_types/serializers.py @@ -1,7 +1,7 @@ from rest_framework import serializers from rest_framework.exceptions import ValidationError -from .models import LabelType, CategoryType, SpanType, RelationTypes +from .models import LabelType, CategoryType, SpanType, RelationType class LabelSerializer(serializers.ModelSerializer): @@ -84,5 +84,5 @@ class RelationTypesSerializer(serializers.ModelSerializer): return super().validate(attrs) class Meta: - model = RelationTypes + model = RelationType fields = ('id', 'color', 'name') diff --git a/backend/label_types/views.py b/backend/label_types/views.py index a3d51784..8297b3c6 100644 --- a/backend/label_types/views.py +++ b/backend/label_types/views.py @@ -11,7 +11,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from members.permissions import IsInProjectReadOnlyOrAdmin, IsProjectAdmin -from .models import LabelType, CategoryType, SpanType, RelationTypes +from .models import LabelType, CategoryType, SpanType, RelationType from .exceptions import LabelValidationError from .serializers import (CategoryTypeSerializer, LabelSerializer, RelationTypesSerializer, SpanTypeSerializer) @@ -70,12 +70,12 @@ class SpanTypeDetail(generics.RetrieveUpdateDestroyAPIView): class RelationTypeList(LabelList): - model = RelationTypes + model = RelationType serializer_class = RelationTypesSerializer class RelationTypeDetail(generics.RetrieveUpdateDestroyAPIView): - queryset = RelationTypes.objects.all() + queryset = RelationType.objects.all() serializer_class = RelationTypesSerializer lookup_url_kwarg = 'relation_type_id' permission_classes = [IsAuthenticated & IsInProjectReadOnlyOrAdmin] diff --git a/backend/labels/models.py b/backend/labels/models.py index 8c425db5..5b8690b5 100644 --- a/backend/labels/models.py +++ b/backend/labels/models.py @@ -4,7 +4,7 @@ from django.db import models from .managers import LabelManager, CategoryManager, SpanManager, TextLabelManager from api.models import Example, Project -from label_types.models import CategoryType, SpanType, RelationTypes +from label_types.models import CategoryType, SpanType, RelationType class Label(models.Model): @@ -108,7 +108,7 @@ class TextLabel(Label): class Relation(models.Model): annotation_id_1 = models.IntegerField() annotation_id_2 = models.IntegerField() - type = models.ForeignKey(RelationTypes, related_name='annotation_relations', on_delete=models.CASCADE) + type = models.ForeignKey(RelationType, related_name='annotation_relations', on_delete=models.CASCADE) timestamp = models.DateTimeField() user = models.ForeignKey(User, related_name='annotation_relations', on_delete=models.CASCADE) project = models.ForeignKey(Project, related_name='annotation_relations', on_delete=models.CASCADE)