constant.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # coding=utf-8
  2. from django.utils.module_loading import import_string
  3. from enum import Enum
  4. from apilib.systypes import IntEnum
  5. class TodoTypeEnum(Enum):
  6. """
  7. 待办消息的种类
  8. """
  9. SMS_TODO = 1, u"流量卡待办", None
  10. @classmethod
  11. def choices(cls):
  12. result = list()
  13. for _ in cls.__members__.values():
  14. result.append(_.code)
  15. return result
  16. @classmethod
  17. def to_list(cls):
  18. return [{"code": _.code, "text": _.text} for _ in cls.__members__.values()]
  19. def __init__(self, code, text, todoCls):
  20. self.code = code
  21. self.text = text
  22. self.todoCls = todoCls
  23. def _load_todoCls(self):
  24. return import_string(self.todoCls)
  25. def __eq__(self, other):
  26. return self.code == other
  27. class TodoDone(IntEnum):
  28. INIT = 0 # 待办任务的初始化
  29. ING = 1 # 待办任务的进行中(目前可能没有用)
  30. DONE = 2 # 待办任务的完成
  31. class LinkageSwitchEnum(object):
  32. CHARGE_INSURANCE = "chargeInsurance"