本文整理汇总了Python中models.user.User.id方法的典型用法代码示例。如果您正苦于以下问题:Python User.id方法的具体用法?Python User.id怎么用?Python User.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import id [as 别名]
def test_get_user(self):
"""
test that a user can be fetched by their local database id
"""
user = User(username='foo', email='bar', googleID = '123').put()
user_id = user.id()
self.assertIsNotNone(get_user(user_id))
self.assertEqual(get_user(user_id).username, 'foo')
示例2: test_create_user
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import id [as 别名]
def test_create_user(self):
time = datetime.now()
user = User()
user.id = 38413
user.profIcon = 3134
user.revisionDate = time
user.level = 30
user.name = 'intoxicated'
self.assertEquals(user.id, 38413)
self.assertEquals(user.profIcon, 3134)
self.assertEquals(user.revisionDate, time)
self.assertEquals(user.level, 30)
self.assertEquals(user.name, 'intoxicated')
示例3: register
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import id [as 别名]
def register():
if request.method == 'POST':
if user_search():
return render_template('login.html')
else:
new = User()
new.id = request.form['user_id']
new.pw = request.form['user_pw']
db.session.add(new)
try:
db.session.commit()
except IntegrityError:
return '중복된 ID 입니다.', 400
resp = make_response(redirect(url_for("index")))
resp.set_cookie('id', new.id)
resp.set_cookie('money', new.money)
return resp
else:
return render_template('register.html')
示例4: register
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import id [as 别名]
def register(params, device):
rtype = params.get('rtype', None)
name = params.get('name', None)
phone = params.get('phone', None)
password = params.get('password', None)
vcode = params.get('vcode', None)
uname = params.get('username', '')
cname = params.get('cname', '')
notice = params.get('notice', "true")
if not phone or not password or not vcode or not name or not rtype or not notice or not rtype.isdigit():
return {"error_code":20021, "msg":"parameters required"}
rtype = int(rtype)
if not validate.is_phone(phone):
return {"error_code":20022, "msg":"phone invalid"}
# freelancer: 1, client: 2, client_person: 3
if rtype not in [1, 2, 3]:
return {"error_code":20022, "msg":"user type invalid"}
if rtype == 2 and not cname or len(cname) > 100:
return {"error_code":20022, "msg":"user type invalid or cname too long"}
if not validate.is_verify_code(vcode):
return {"error_code":20024, "msg":"verify code invalid"}
if User.select().where(User.phone == phone).first():
return {"error_code":20025, "msg":"user is exists"}
if rtype != 1:
username = phone
else:
# freelancer do not use username, just use phone to register
# username = uname
username = phone
if not utils.is_username(username):
return {"error_code":20023, "msg":"username invalid"}
if User.select().where(User.username == username).first():
return {"error_code":20025, "msg":"user is exists"}
res = verify_code(phone=phone, code=vcode)
if res['error_code'] != 0:
return res
user_id = GUID.guid()
team_id = GUID.guid()
with database.atomic() as txn:
try:
pwd, salt = generate_password(password.encode('utf-8'))
user = User()
user.id = user_id
user.username = username
user.password = pwd
user.salt = salt
user.phone = phone
#user.verifycode = vcode
user.save(force_insert=True)
profile = Profile()
profile.user = user
profile.name = name
profile.avatar = widget.avatar()
if notice == "true":
profile.is_notice = True
profile.save()
party = Party()
party.user = user
party.vip = False
party.connects = 60
party.agency_connects = 60
party.save()
margin = Margin()
margin.user = user
margin.save()
if rtype == 1:
user.identify = 'f%s' % user.id
user.app_identify = 'f%s' % user.id
user.status = "unactive"
user.to_dev = True
user.to_req = False
user.save()
queue.to_queue({"type":"user_register", "user_id":user.id})
else:
team = Team()
team.id = team_id
team.user = user
if rtype == 2:
team.name = cname
else:
team.name = "个人需求方"
team.team_type = 'client'
team.status = "normal"
#.........这里部分代码省略.........