本文整理汇总了Python中models.Profile.update_from_user方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.update_from_user方法的具体用法?Python Profile.update_from_user怎么用?Python Profile.update_from_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.update_from_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import update_from_user [as 别名]
def setUp(self):
super(TestUserMerge, self).setUp()
user1 = User.query.filter_by(username=u'user1').one()
user2 = User.query.filter_by(username=u'user2').one()
user2.merge_into(user1)
# Normally this would be done by Lastuser:
user1.userinfo[u'oldids'] = [user2.userid]
db.session.commit()
# Update profiles
Profile.update_from_user(user1, db.session)
self.user1 = User.query.filter_by(userid=u"1234567890123456789012").one()
self.user2 = User.query.filter_by(userid=u"0987654321098765432109").one()
self.user3 = User.query.filter_by(userid=u"1234567890987654321234").one()
self.team1 = Team.query.filter_by(userid=u"1324354657687980089786").one()
self.team2 = Team.query.filter_by(userid=u"0897867564534231243546").one()
self.team3 = Team.query.filter_by(userid=u"1324354657687980132435").one()
示例2: setUp
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import update_from_user [as 别名]
def setUp(self):
super(TestUserMerge, self).setUp()
user1 = User.query.filter_by(username=u'user1').one()
user2 = User.query.filter_by(username=u'user2').one()
user2.merge_into(user1)
# Normally this would be done by Lastuser:
user1.userinfo[u'oldids'] = [user2.userid]
db.session.commit()
# Update profiles
Profile.update_from_user(user1, db.session)
self.user1 = User.query.filter_by(userid=u"1234567890123456789012").one()
self.user2 = User.query.filter_by(userid=u"0987654321098765432109").one()
self.user3 = User.query.filter_by(userid=u"1234567890987654321234").one()
self.team1 = Team.query.filter_by(userid=u"1324354657687980089786").one()
self.team2 = Team.query.filter_by(userid=u"0897867564534231243546").one()
self.team3 = Team.query.filter_by(userid=u"1324354657687980132435").one()
def request_callback(request, uri, headers):
if 'userid' in request.parsed_body and request.parsed_body['userid'][0] == '0987654321098765432109':
response = {
"status": "ok",
"type": "user",
"buid": "1234567890123456789012",
"userid": "1234567890123456789012",
"name": "user1",
"title": "User 1",
"label": "User 1 (~user1)",
"oldids": ['0987654321098765432109'],
"timezone": "Asia/Kolkata",
}
else:
response = {'status': 'error', 'error': 'not_found'}
return (200, headers, json.dumps(response))
httpretty.enable()
httpretty.register_uri(httpretty.POST, self.lastuser.endpoint_url(self.lastuser.getuser_userid_endpoint),
body=request_callback,
content_type="application/json")
示例3: create_test_data
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import update_from_user [as 别名]
def create_test_data(self):
user1 = User(userid=u"1234567890123456789012", username=u"user1", fullname=u"User 1",
email=u'[email protected]',
userinfo={
u'timezone': u'Asia/Kolkata',
u'organizations': {
u'member': [
{
u'userid': u'qazwsxedcrfvtgbyhnujmi',
u'name': u'org1',
u'title': u'Organization 1',
},
],
u'owner': [
{
u'userid': u'qazwsxedcrfvtgbyhnujmi',
u'name': u'org1',
u'title': u'Organization 1',
},
]
}
})
user2 = User(userid=u"0987654321098765432109", username=u"user2", fullname=u"User 2",
email=u'[email protected]',
userinfo={
u'timezone': u'Asia/Kolkata',
u'organizations': {
u'member': [
{
u'userid': u'qwertyuiopasdfghjklzxc',
u'name': u'org2',
u'title': u'Organization 2',
},
{
u'userid': u'mnbvcxzlkjhgfdsapoiuyt',
u'name': u'org3',
u'title': u'Organization 3',
},
],
u'owner': [
{
u'userid': u'qwertyuiopasdfghjklzxc',
u'name': u'org2',
u'title': u'Organization 2',
},
{
'userid': 'mnbvcxzlkjhgfdsapoiuyt',
'name': 'org3',
'title': 'Organization 3',
},
]
}
})
user3 = User(userid=u"1234567890987654321234", username=u"user3", fullname=u"User 3",
email=u'[email protected]',
userinfo={
u'timezone': 'Asia/Kolkata',
u'organizations': {
u'member': [
{
u'userid': u'mnbvcxzlkjhgfdsapoiuyt',
u'name': u'org3',
u'title': u'Organization 3',
},
{
u'userid': u'qazwsxedcrfvtgbyhnujmi',
u'name': u'org1',
u'title': u'Organization 1',
},
],
u'owner': [
{
u'userid': u'mnbvcxzlkjhgfdsapoiuyt',
u'name': u'org3',
u'title': u'Organization 3',
},
{
u'userid': u'qazwsxedcrfvtgbyhnujmi',
u'name': u'org1',
u'title': u'Organization 1',
},
]
}
})
team1 = Team(userid=u"1324354657687980089786", orgid=u"qazwsxedcrfvtgbyhnujmi",
title=u"Team 1", users=[user1, user2])
team2 = Team(userid=u"0897867564534231243546", orgid=u"qwertyuiopasdfghjklzxc",
title=u"Team 2", users=[user2, user3])
team3 = Team(userid=u"1324354657687980132435", orgid=u"mnbvcxzlkjhgfdsapoiuyt",
title=u"Team 3", users=[user3, user1])
db.session.add_all([user1, user2, user3, team1, team2, team3])
db.session.flush()
# Create six profiles (3 users + 3 orgs)
Profile.update_from_user(user1, db.session)
Profile.update_from_user(user2, db.session)
Profile.update_from_user(user3, db.session)
#.........这里部分代码省略.........