def add_moz_zero_charge(orm): mzn, _ = (orm['accounting.Currency'] if orm else Currency).objects.get_or_create(code='MZN') sms_gateway_fee_class = orm[ 'smsbillables.SmsGatewayFee'] if orm else SmsGatewayFee sms_gateway_fee_criteria_class = orm[ 'smsbillables.SmsGatewayFeeCriteria'] if orm else SmsGatewayFeeCriteria SmsGatewayFee.create_new( 'SISLOG', INCOMING, Decimal('0'), country_code=None, prefix='', currency=mzn, fee_class=sms_gateway_fee_class, criteria_class=sms_gateway_fee_criteria_class, ) backend_id = '7ddf3301c093b793c6020ebf755adb6f' try: backend = HttpBackend.get(backend_id) SmsGatewayFee.create_new( backend.get_api_id(), OUTGOING, Decimal('0'), backend_instance=backend._id, country_code=None, prefix='', currency=mzn, fee_class=sms_gateway_fee_class, criteria_class=sms_gateway_fee_criteria_class, ) logger.info("Updated Moz gateway default fees.") except ResourceNotFound: logger.error( "[SMS-BILLING] Could not find HttpBackend %s - did not create outgoing Moz gateway default fees." " Please look into if this is on production, otherwise ignore." % backend_id)
def add_moz_zero_charge(orm): mzn, _ = (orm['accounting.Currency'] if orm else Currency).objects.get_or_create(code='MZN') sms_gateway_fee_class = orm['smsbillables.SmsGatewayFee'] if orm else SmsGatewayFee sms_gateway_fee_criteria_class = orm['smsbillables.SmsGatewayFeeCriteria'] if orm else SmsGatewayFeeCriteria SmsGatewayFee.create_new( 'SISLOG', INCOMING, Decimal('0'), country_code=None, prefix='', currency=mzn, fee_class=sms_gateway_fee_class, criteria_class=sms_gateway_fee_criteria_class, ) backend_id = '7ddf3301c093b793c6020ebf755adb6f' try: backend = HttpBackend.get(backend_id) SmsGatewayFee.create_new( backend.get_api_id(), OUTGOING, Decimal('0'), backend_instance=backend._id, country_code=None, prefix='', currency=mzn, fee_class=sms_gateway_fee_class, criteria_class=sms_gateway_fee_criteria_class, ) logger.info("Updated Moz gateway default fees.") except ResourceNotFound: logger.error("[SMS-BILLING] Could not find HttpBackend %s - did not create outgoing Moz gateway default fees." " Please look into if this is on production, otherwise ignore." % backend_id)
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()