Browse Source

Add is_text_project field to ProjectSerializer

pull/1632/head
Hironsan 2 years ago
parent
commit
06be25d336
3 changed files with 13 additions and 12 deletions
  1. 2
      backend/api/models.py
  2. 2
      backend/api/serializers.py
  3. 21
      frontend/domain/models/project/project.ts

2
backend/api/models.py

@ -43,7 +43,7 @@ class Project(PolymorphicModel):
@property
@abc.abstractmethod
def is_text_project(self) -> bool:
raise NotImplementedError()
return False
def __str__(self):
return self.name

2
backend/api/serializers.py

@ -173,11 +173,13 @@ class ProjectSerializer(serializers.ModelSerializer):
'random_order',
'collaborative_annotation',
'single_class_classification',
'is_text_project',
'tags'
)
read_only_fields = (
'updated_at',
'users',
'is_text_project',
'tags'
)

21
frontend/domain/models/project/project.ts

@ -17,6 +17,7 @@ export class ProjectReadItem {
public allow_overlapping: boolean,
public grapheme_mode: boolean,
public tags: Object[],
public is_text_project: boolean,
) {}
static valueOf(
@ -34,7 +35,8 @@ export class ProjectReadItem {
resourcetype,
allow_overlapping,
grapheme_mode,
tags
tags,
is_text_project
}:
{
id: number,
@ -50,7 +52,8 @@ export class ProjectReadItem {
resourcetype: string,
allow_overlapping: boolean,
grapheme_mode: boolean,
tags: Object[]
tags: Object[],
is_text_project: boolean
}
): ProjectReadItem {
return new ProjectReadItem(
@ -67,7 +70,8 @@ export class ProjectReadItem {
resourcetype,
allow_overlapping,
grapheme_mode,
tags
tags,
is_text_project
)
}
@ -102,13 +106,7 @@ export class ProjectReadItem {
}
get isTextProject() {
const allowedProjectTypes = [
'DocumentClassification',
'SequenceLabeling',
'Seq2seq',
'IntentDetectionAndSlotFilling'
]
return allowedProjectTypes.includes(this.project_type)
return this.is_text_project
}
get hasCategory(): boolean {
@ -143,7 +141,8 @@ export class ProjectReadItem {
resourcetype: this.resourcetype,
allow_overlapping: this.allow_overlapping,
grapheme_mode: this.grapheme_mode,
tags: this.tags
tags: this.tags,
is_text_project: this.is_text_project
}
}
}

Loading…
Cancel
Save