sysparas.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. from django.conf import settings
  4. from apps.web.core.messages import SmsVendorCode
  5. from apps.web.core.models import SystemSettings
  6. from configs.servers import PUBLIC_MAP_PRIVATE
  7. class SysParas(object):
  8. @classmethod
  9. def get_sms_vendor(cls, priority = None, default = SmsVendorCode.UCPAAS):
  10. if priority:
  11. return priority
  12. return SystemSettings.get_system_setting('smsVendor', default)
  13. @classmethod
  14. def get_system_alarmer(cls):
  15. value = SystemSettings.get_system_setting('systemAlarmer')
  16. if value:
  17. return list(value)
  18. else:
  19. return []
  20. @classmethod
  21. def get_special_privilage(cls, role):
  22. value = SystemSettings.get_system_setting('specialPrivilage')
  23. if value:
  24. return dict(value).get(role, {})
  25. else:
  26. return {}
  27. @classmethod
  28. def get_platform_app_id_list(cls, gateway):
  29. pass
  30. @classmethod
  31. def get_private_ip(cls, public_ip):
  32. if settings.USE_PRIVATE_MQTT:
  33. return PUBLIC_MAP_PRIVATE.get(public_ip, public_ip)
  34. else:
  35. return str(public_ip)