本文整理汇总了Python中corehq.apps.sms.mixin.MobileBackend.view方法的典型用法代码示例。如果您正苦于以下问题:Python MobileBackend.view方法的具体用法?Python MobileBackend.view怎么用?Python MobileBackend.view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.sms.mixin.MobileBackend
的用法示例。
在下文中一共展示了MobileBackend.view方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from corehq.apps.sms.mixin import MobileBackend [as 别名]
# 或者: from corehq.apps.sms.mixin.MobileBackend import view [as 别名]
def handle(self, *args, **options):
backends = MobileBackend.view("sms/old_mobile_backend", include_docs=True).all()
for backend in backends:
print "Processing backend %s" % backend._id
if backend._id == "MOBILE_BACKEND_UNICEL":
backend = UnicelBackend.wrap(backend.to_json())
backend.doc_type = "UnicelBackend"
backend.domain = None
backend.name = backend._id
backend.authorized_domains = []
backend.is_global = True
backend.username = settings.UNICEL_CONFIG.get("username")
backend.password = settings.UNICEL_CONFIG.get("password")
backend.sender = settings.UNICEL_CONFIG.get("sender")
backend.reply_to_phone_number = settings.UNICEL_CONFIG.get("receive_phone", None)
backend.outbound_module = None
backend.outbound_params = None
backend.save()
elif backend._id == "MOBILE_BACKEND_MACH":
backend = MachBackend.wrap(backend.to_json())
backend.doc_type = "MachBackend"
backend.domain = None
backend.name = backend._id
backend.authorized_domains = []
backend.is_global = True
backend.account_id = re.match(r".*id=(.+?)&", settings.SMS_GATEWAY_PARAMS).group(1)
backend.password = re.match(r".*pw=(.+?)&", settings.SMS_GATEWAY_PARAMS).group(1)
backend.sender_id = "DIMAGI"
backend.outbound_module = None
backend.outbound_params = None
backend.save()
elif backend.outbound_module == "corehq.apps.tropo.api":
backend = TropoBackend.wrap(backend.to_json())
backend.doc_type = "TropoBackend"
backend.domain = None
backend.name = backend._id
backend.authorized_domains = []
backend.is_global = True
backend.messaging_token = backend.outbound_params.get("messaging_token")
backend.outbound_module = None
backend.outbound_params = None
backend.save()
elif backend.outbound_module == "corehq.apps.sms.backend.http_api":
print "REMINDER: Need to set global / domain for backend %s" % backend._id
backend = HttpBackend.wrap(backend.to_json())
backend.doc_type = "HttpBackend"
backend.domain = None
backend.name = backend._id
backend.authorized_domains = []
backend.is_global = False
backend.url = backend.outbound_params.get("url")
backend.message_param = backend.outbound_params.get("message_param")
backend.number_param = backend.outbound_params.get("number_param")
backend.include_plus = backend.outbound_params.get("include_plus", False)
backend.method = backend.outbound_params.get("method", "GET")
backend.additional_params = backend.outbound_params.get("additional_params", {})
backend.outbound_module = None
backend.outbound_params = None
backend.save()
elif backend.outbound_module == "corehq.apps.sms.test_backend":
backend = TestSMSBackend.wrap(backend.to_json())
backend.doc_type = "TestSMSBackend"
backend.domain = None
backend.name = backend._id
backend.authorized_domains = []
backend.is_global = True
backend.outbound_module = None
backend.outbound_params = None
backend.save()