本文整理汇总了Python中src.models.user.User.find_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python User.find_by_email方法的具体用法?Python User.find_by_email怎么用?Python User.find_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.models.user.User
的用法示例。
在下文中一共展示了User.find_by_email方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: admin_edit_profile_page
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def admin_edit_profile_page(user):
universities = University.get_uni_list()
profile = User.find_by_email(user)
mypermissions = User.get_user_permissions(session['email'])
permissions = [permission_level for permission_level in Database.find(Permissions.COLLECTION, {})]
return render_template('edit-profile.html', user=user, universities=universities, profile=profile,
permissions=permissions, mypermissions=mypermissions)
示例2: test_save_simple_user_to_db
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def test_save_simple_user_to_db(self):
email = "[email protected]"
user = User(email, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
user.permissions = Permissions.default().name
user.save_to_db()
self.assertIsNotNone(User.find_by_email(email))
Database.remove("users", {"email": email})
示例3: edit_profile
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def edit_profile():
if User.check_login(session['email'], request.form['password']):
user = User.find_by_email(session['email'])
user.data.update(firstname=request.form['firstname'], lastname=request.form['lastname'],
university=request.form['university'], level=request.form['level'],
country=request.form['country'], school=request.form['college'],
subject=request.form['course'], year=request.form['yearofstudy'])
user.save_to_db()
return make_response(view_profile())
else:
return render_template('user-profile.html', message="Incorrect Password")
示例4: admin_update_user_profile
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def admin_update_user_profile():
if User.check_login(session['email'], request.form['password']):
user = User.find_by_email(request.form['email'])
user.data.update(firstname=request.form['firstname'], lastname=request.form['lastname'],
university=request.form['university'], level=request.form['level'],
country=request.form['country'], school=request.form['college'],
subject=request.form['course'], year=request.form['yearofstudy'],
permissions=request.form['permissions'])
user.save_to_db()
return redirect("/admin/view-profile/" + request.form['email'])
else:
return render_template('user-profile.html', message="Incorrect Password")
示例5: view_profile
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def view_profile():
if session.contains('email') and session['email'] is not None:
profile = User.find_by_email(session['email'])
events = profile.get_registered_events(session['email'])
attended_events = profile.get_all_attended(session['email'])
current_date = datetime.now()
#current_date = current_date.strftime("%d-%m-%Y at %H:%M")
totalpoints = profile.total_points()
user_points = profile.data['points'] if 'points' in profile.data.keys() else None
awards = []
if user_points is not None:
awards = Award.check_user_awards(profile.data['points'])
return render_template('user-profile.html', profile=profile, events=events, attended_events=attended_events, totalpoints=totalpoints,
rank=profile.get_point_rank(), awards=awards, date=current_date)
else:
return render_template('user-profile.html', message="Not Logged In")
示例6: admin_view_profile
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def admin_view_profile(user_email):
if session.contains('email') and session['email'] is not None:
if User.get_user_permissions(session['email']) == 'admin':
profile = User.find_by_email(user_email)
events = profile.get_registered_events(profile.email)
totalpoints = profile.total_points()
attended_events = profile.get_all_attended(profile.email)
current_date = datetime.now()
permissions = User.get_user_permissions(session['email'])
user_points = profile.data['points'] if 'points' in profile.data.keys() else None
awards = []
if user_points is not None:
awards = Award.check_user_awards(profile.data['points'])
return render_template('user-profile.html', email=user_email, profile=profile, events=events, totalpoints=totalpoints,
rank=profile.get_point_rank(), permissions=permissions, date=current_date,
attended_events=attended_events, awards=awards)
else:
abort(401)
示例7: test_save_complex_user_to_db
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def test_save_complex_user_to_db(self):
email = "[email protected]"
encrypted_password = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
country = "Spain"
university = "Abertay"
user = User(email, encrypted_password)
user.data['country'] = country
user.data['university'] = university
user.permissions = Permissions.default().name
user.save_to_db()
user_from_db = User.find_by_email(email)
self.assertEqual(user_from_db.email, email)
self.assertEqual(user_from_db.encrypted_password, encrypted_password)
self.assertEqual(user_from_db.data['country'], country)
self.assertEqual(user_from_db.data['university'], university)
Database.remove("users", {"email": email})
示例8: edit_profile_page
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def edit_profile_page():
universities = University.get_uni_list()
profile = User.find_by_email(session['email'])
return render_template('edit-profile.html', universities=universities, profile=profile)
示例9: get_access_level
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def get_access_level():
if session.contains('email') and session['email'] is not None:
return User.find_by_email(session['email']).permissions
return ""
示例10: func_wrapper
# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import find_by_email [as 别名]
def func_wrapper(*args, **kwargs):
if session.contains('email') and session['email'] is not None and User.find_by_email(
session['email']).allowed(type):
return make_response(func(*args, **kwargs))
else:
abort(401)