category.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from .model import model
  2. from .proxy import proxy
  3. from .single_set_proxy import single_set_proxy
  4. from .single_set_model import single_set_model
  5. from .field_generator import field_generator
  6. from .validators import validators
  7. from .single_set_manager import single_set_manager
  8. from .constants import constants
  9. class category(single_set_model):
  10. """
  11. This class represents single category of items in application. Category
  12. must be an strincg, where all letters are small, Category name can also
  13. contains numbers, and "-", "_".
  14. Fields
  15. -------
  16. content : str
  17. Content of the category.
  18. Methods
  19. -------
  20. get_proxy : class <single_set_proxy>
  21. Return proxy for that model.
  22. """
  23. content = field_generator.name()
  24. def _single_validator(self) -> callable:
  25. return validators.name
  26. class category_manager(
  27. single_set_manager,
  28. target_model = category,
  29. related_models = constants.get_related_name("item")
  30. ):
  31. """
  32. This is manager for categories in app. It base on single set proxu, and
  33. for more informations, how to use it, see single_set_manager.
  34. """
  35. pass