constant.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. MER_TODO = 2, u"商户待办", "apps.web.dealer.utils.MerchantTodo"
  11. @classmethod
  12. def choices(cls):
  13. result = list()
  14. for _ in cls.__members__.values():
  15. result.append(_.code)
  16. return result
  17. @classmethod
  18. def to_list(cls):
  19. return [{"code": _.code, "text": _.text} for _ in cls.__members__.values()]
  20. def __init__(self, code, text, todoCls):
  21. self.code = code
  22. self.text = text
  23. self.todoCls = todoCls
  24. def _load_todoCls(self):
  25. return import_string(self.todoCls)
  26. def __eq__(self, other):
  27. return self.code == other
  28. class TodoDone(IntEnum):
  29. INIT = 0 # 待办任务的初始化
  30. ING = 1 # 待办任务的进行中(目前可能没有用)
  31. DONE = 2 # 待办任务的完成
  32. class LinkageSwitchEnum(object):
  33. CHARGE_INSURANCE = "chargeInsurance"