本文整理汇总了Python中users.models.Profile.buyer_or_seller方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.buyer_or_seller方法的具体用法?Python Profile.buyer_or_seller怎么用?Python Profile.buyer_or_seller使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.models.Profile
的用法示例。
在下文中一共展示了Profile.buyer_or_seller方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_user
# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import buyer_or_seller [as 别名]
def add_user(doc):
if doc['mobile'] in sellers: return
u = User()
try:
u = User.objects.get(username=doc['mobile'])
except User.DoesNotExist:
pass
u.username = doc['mobile']
if 'timestamp' in doc:
u.timestamp = doc['timestamp'].strftime('%Y-%m-%d %H:%M:%S')
else:
if 'modificationTime' in doc:
u.timestamp = doc['modificationTime'].strftime('%Y-%m-%d %H:%M:%S')
u.save()
p = Profile()
try:
p = Profile.objects.get(primary_phone=doc['mobile'])
if p.id != doc['id']:
record_duplicate(p.id, doc['id'])
return
except Profile.DoesNotExist:
pass
p.id = doc['id']
p.user = u
p.full_name = doc.get('name','')
p.gender = doc.get('gender','').lower()
if len(p.gender) > 1:
p.gender = p.gender[0]
if doc.get('dateOfBirth',None):
p.date_of_birth = doc['dateOfBirth'].strftime('%Y-%m-%d')
p.primary_phone = doc['mobile']
p.secondary_phone = doc.get('mobile2','')
p.primary_email = doc.get('email','').split(',')[0]
p.secondary_email = doc.get('email2','').split(',')[0]
p.buyer_or_seller = 'buyer'
p.type = doc.get('type','individual')
p.marketing_alerts = doc.get('dealAlerts','neutral')
p.salt = doc.get('salt','')
p.passcode = doc.get('passcode','')
p.created_on = u.timestamp
p.save()