Browse Source

Remove image property from Project models and serializers, fix #713

pull/1161/head
Hironsan 3 years ago
parent
commit
eb43f17882
2 changed files with 4 additions and 25 deletions
  1. 21
      app/api/models.py
  2. 8
      app/api/serializers.py

21
app/api/models.py

@ -6,7 +6,6 @@ from django.db.models.signals import post_save, pre_delete
from django.urls import reverse
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.exceptions import ValidationError
from polymorphic.models import PolymorphicModel
@ -39,10 +38,6 @@ class Project(PolymorphicModel):
def get_absolute_url(self):
return reverse('upload', args=[self.id])
@property
def image(self):
raise NotImplementedError()
def get_bundle_name(self):
raise NotImplementedError()
@ -67,10 +62,6 @@ class Project(PolymorphicModel):
class TextClassificationProject(Project):
@property
def image(self):
return staticfiles_storage.url('assets/images/cats/text_classification.jpg')
def get_bundle_name(self):
return 'document_classification'
@ -94,10 +85,6 @@ class TextClassificationProject(Project):
class SequenceLabelingProject(Project):
@property
def image(self):
return staticfiles_storage.url('assets/images/cats/sequence_labeling.jpg')
def get_bundle_name(self):
return 'sequence_labeling'
@ -121,10 +108,6 @@ class SequenceLabelingProject(Project):
class Seq2seqProject(Project):
@property
def image(self):
return staticfiles_storage.url('assets/images/cats/seq2seq.jpg')
def get_bundle_name(self):
return 'seq2seq'
@ -148,10 +131,6 @@ class Seq2seqProject(Project):
class Speech2textProject(Project):
@property
def image(self):
return staticfiles_storage.url('images/cats/speech2text.jpg')
def get_bundle_name(self):
return 'speech2text'

8
app/api/serializers.py

@ -119,9 +119,9 @@ class ProjectSerializer(serializers.ModelSerializer):
class Meta:
model = Project
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image',
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type',
'updated_at', 'randomize_document_order', 'collaborative_annotation', 'single_class_classification')
read_only_fields = ('image', 'updated_at', 'users', 'current_users_role')
read_only_fields = ('updated_at', 'users', 'current_users_role')
class TextClassificationProjectSerializer(ProjectSerializer):
@ -152,9 +152,9 @@ class Speech2textProjectSerializer(ProjectSerializer):
class Meta:
model = Speech2textProject
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type', 'image',
fields = ('id', 'name', 'description', 'guideline', 'users', 'current_users_role', 'project_type',
'updated_at', 'randomize_document_order')
read_only_fields = ('image', 'updated_at', 'users', 'current_users_role')
read_only_fields = ('updated_at', 'users', 'current_users_role')
class ProjectPolymorphicSerializer(PolymorphicSerializer):

Loading…
Cancel
Save