本文整理汇总了Python中models.Member.member_phone方法的典型用法代码示例。如果您正苦于以下问题:Python Member.member_phone方法的具体用法?Python Member.member_phone怎么用?Python Member.member_phone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Member
的用法示例。
在下文中一共展示了Member.member_phone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submitname
# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import member_phone [as 别名]
def submitname(request):
first_name = request.POST.get("first_name", None)
contact_info = request.POST.get("contact_info", None)
context = {}
custom_errors = ""
if (first_name):
context["first_name"] = first_name
if (contact_info):
context["contact_info"] = contact_info
# Create a circle
new_circle = Circle(circle_name=first_name + "'s circle",
circle_created_date=timezone.now(), )
new_circle.save()
# Create our new member
new_member = Member(circle=new_circle,
circle_owner=True,
member_name=first_name,
member_created_date=timezone.now(), )
# Check to see if current contact info is valid phone or email
if is_phone(contact_info):
new_phone = phonenumbers.parse(contact_info, "US")
new_phone = phonenumbers.format_number(new_phone, phonenumbers.PhoneNumberFormat.E164)
new_member.member_phone = new_phone
if is_email(contact_info):
new_member.member_email = contact_info
if not is_phone(contact_info) and not is_email(contact_info):
# Bad data error
custom_errors += "<li>contact info must be either a valid phone number OR email</li>"
new_member.save()
set_member_and_circle(request, new_circle, new_member)
else:
# Missing contact data error
custom_errors += "<li>name is present but contact info is missing</li>"
else:
# Missing name data error
custom_errors += "<li>"
if (contact_info):
context["contact_info"] = contact_info
custom_errors += "contact info is present but "
custom_errors += "name is missing</li>"
if custom_errors != "":
custom_errors = format_html("<p><ul>{}</ul></p>",
mark_safe(custom_errors))
# If there are any errors, kick out and display them
context["custom_errors"] = custom_errors
context["anchor"] = "signup"
return render(request, "circly/index.html", context)
return HttpResponseRedirect(reverse("connect:flow",
kwargs={}))