本文整理汇总了Python中users.models.Profile.created_on方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.created_on方法的具体用法?Python Profile.created_on怎么用?Python Profile.created_on使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.models.Profile
的用法示例。
在下文中一共展示了Profile.created_on方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_user_profile
# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import created_on [as 别名]
def get_user_profile(user):
""" Returns user profile. Creates one if needed """
if not (user and user.is_authenticated()):
return None
pr = cache.get("users_profile:auth_user=%s" % user.id, None)
if pr:
return pr
pr = get_profile_by_email_or_phone(user.username)
if not pr:
pr = Profile.objects.filter(user=user).order_by("id")[:2]
if len(pr) > 1:
fb_log.info("Multiple profiles for user: %s" % user.username)
if pr:
pr = pr[0]
if not pr:
pr = Profile(user=user)
pr.created_on = datetime.now()
pr.save()
if is_valid_email(user.username):
try:
email = Email(email=user.username, user=pr, type="primary")
email.save()
except:
pass
if is_valid_mobile(user.username):
try:
phone = Phone(phone - user.username, user=pr, type="primary")
phone.save()
except:
pass
cache.set("users_profile:auth_user=%s" % user.id, pr)
return pr
示例2: add_user
# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import created_on [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()
示例3: get_agent
# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import created_on [as 别名]
def get_agent(self, agent_name):
try:
usr = User.objects.get(username=agent_name)
p = usr.get_profile()
return p
except User.DoesNotExist:
try:
usr = User.objects.create_user(agent_name, '%[email protected]' % agent_name)
usr.save()
p = Profile(user=usr, primary_phone=agent_name)
p.created_on = datetime.datetime.now()
p.save()
return p
except Exception, e:
log.error('Error creating agent %s' % repr(e))
return None
示例4: Profile
# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import created_on [as 别名]
p = usr.get_profile()
return p
except User.DoesNotExist:
try:
usr = User.objects.create_user(agent_name, '%[email protected]' % agent_name)
usr.save()
p = Profile(user=usr, primary_phone=agent_name)
p.created_on = datetime.datetime.now()
p.save()
return p
except Exception, e:
log.error('Error creating agent %s' % repr(e))
return None
except Profile.DoesNotExist:
p = Profile(user=usr, primary_phone=agent_name, )
p.created_on = datetime.datetime.now()
p.save()
return p
def create_order(self, profile, old_order):
order = Order()
try:
order.id = old_order.id
order.state = old_order.state
order.user = profile
order.reference_order_id = old_order.friendlyorderid
if old_order.paymentmode:
order.payment_mode = self.get_related_payment_mode(old_order.paymentmode)
if old_order.paymentrealizedmode: