本文整理汇总了Python中corehq.apps.accounting.models.BillingAccount.get_enterprise_restricted_signup_accounts方法的典型用法代码示例。如果您正苦于以下问题:Python BillingAccount.get_enterprise_restricted_signup_accounts方法的具体用法?Python BillingAccount.get_enterprise_restricted_signup_accounts怎么用?Python BillingAccount.get_enterprise_restricted_signup_accounts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.accounting.models.BillingAccount
的用法示例。
在下文中一共展示了BillingAccount.get_enterprise_restricted_signup_accounts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_username_availability
# 需要导入模块: from corehq.apps.accounting.models import BillingAccount [as 别名]
# 或者: from corehq.apps.accounting.models.BillingAccount import get_enterprise_restricted_signup_accounts [as 别名]
def check_username_availability(self, data):
email = data['email'].strip()
duplicate = CouchUser.get_by_username(email)
is_existing = User.objects.filter(username__iexact=email).count() > 0 or duplicate
message = None
restricted_by_domain = None
if is_existing:
message = _("There is already a user with this email.")
else:
domain = email[email.find("@") + 1:]
for account in BillingAccount.get_enterprise_restricted_signup_accounts():
if domain in account.enterprise_restricted_signup_domains:
restricted_by_domain = domain
message = account.restrict_signup_message
regex = r'(\b[a-zA-Z0-9_.+%-][email protected][a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+\b)'
subject = _("CommCareHQ account request")
message = re.sub(regex, "<a href='mailto:\\1?subject={}'>\\1</a>".format(subject), message)
break
return {
'isValid': message is None,
'restrictedByDomain': restricted_by_domain,
'message': message,
}