本文整理匯總了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()