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)
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)
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)
def test_save_simple_user_to_db(self): email = "*****@*****.**" 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})
def test_save_simple_user_to_db(self): email = "*****@*****.**" 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})
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")
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")
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)
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")
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)
def test_save_complex_user_to_db(self): email = "*****@*****.**" encrypted_password = "******" 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})
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")
def __post_init__(self): self.item = Item.get_by_id(self.item_id) self.user = User.find_by_email(self.user_email)
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)
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)
def get_access_level(): if session.contains('email') and session['email'] is not None: return User.find_by_email(session['email']).permissions return ""