Browse Source

Update project model

pull/10/head
Hironsan 6 years ago
parent
commit
7fa18de3d3
1 changed files with 7 additions and 1 deletions
  1. 8
      app/server/models.py

8
app/server/models.py

@ -4,7 +4,7 @@ from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.staticfiles.storage import staticfiles_storage from django.contrib.staticfiles.storage import staticfiles_storage
from .serializers import *
class Project(models.Model): class Project(models.Model):
@ -66,6 +66,9 @@ class Project(models.Model):
return docs return docs
def get_project_serializer(self): def get_project_serializer(self):
from .serializers import DocumentSerializer
from .serializers import SequenceSerializer
from .serializers import Seq2seqSerializer
if self.is_type_of(Project.DOCUMENT_CLASSIFICATION): if self.is_type_of(Project.DOCUMENT_CLASSIFICATION):
return DocumentSerializer return DocumentSerializer
elif self.is_type_of(Project.SEQUENCE_LABELING): elif self.is_type_of(Project.SEQUENCE_LABELING):
@ -76,6 +79,9 @@ class Project(models.Model):
raise ValueError('Invalid project_type') raise ValueError('Invalid project_type')
def get_annotation_serializer(self): def get_annotation_serializer(self):
from .serializers import DocumentAnnotationSerializer
from .serializers import SequenceAnnotationSerializer
from .serializers import Seq2seqAnnotationSerializer
if self.is_type_of(Project.DOCUMENT_CLASSIFICATION): if self.is_type_of(Project.DOCUMENT_CLASSIFICATION):
return DocumentAnnotationSerializer return DocumentAnnotationSerializer
elif self.is_type_of(Project.SEQUENCE_LABELING): elif self.is_type_of(Project.SEQUENCE_LABELING):

Loading…
Cancel
Save