You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
748 B

  1. from typing import Any, Dict, Protocol, Tuple
  2. from django.db import models
  3. from labels.models import Category
  4. class ExportedLabelManager(models.Manager):
  5. pass
  6. class ExportedLabel(Protocol):
  7. objects: models.Manager = ExportedLabelManager()
  8. def to_dict(self) -> Dict[str, Any]:
  9. raise NotImplementedError("Please implement this method in the subclass.")
  10. def to_string(self) -> str:
  11. raise NotImplementedError("Please implement this method in the subclass.")
  12. def to_tuple(self) -> Tuple:
  13. raise NotImplementedError("Please implement this method in the subclass.")
  14. class ExportedCategory(Category):
  15. def to_string(self) -> str:
  16. return self.label.text
  17. class Meta:
  18. proxy = True