Browse Source

Extract methods to super class

pull/1650/head
Hironsan 3 years ago
parent
commit
36c3f55391
1 changed files with 9 additions and 6 deletions
  1. 15
      backend/api/managers.py

15
backend/api/managers.py

@ -29,18 +29,21 @@ class AnnotationManager(Manager):
distribution[username][label] = count
return distribution
def can_annotate(self, label, project) -> bool:
raise NotImplementedError('Please implement this method in the subclass')
class CategoryManager(AnnotationManager):
def get_labels(self, label, project):
if project.collaborative_annotation:
return self.filter(example=label.example)
else:
return self.filter(example=label.example, user=label.user)
def can_annotate(self, label, project) -> bool:
raise NotImplementedError('Please implement this method in the subclass')
def filter_annotatable_labels(self, labels, project):
return [label for label in labels if self.can_annotate(label, project)]
class CategoryManager(AnnotationManager):
def can_annotate(self, label, project) -> bool:
is_exclusive = project.single_class_classification
categories = self.get_labels(label, project)

Loading…
Cancel
Save