def user_profile_page(user_id): if request.method == 'GET': user = UserDatabaseOPS.select_user_with_id(user_id) real_name = UserDatabaseOPS.select_user_name_surname(user.username) return render_template('user_profile.html', signedin=True, user=user, real_name=real_name) else: if 'changeImage' in request.form: user = UserDatabaseOPS.select_user_with_id(user_id) user.profile_pic = request.form['imageURL'] my_name = request.form['my_name'] my_surname = request.form['my_surname'] user.cover_pic = request.form['coverURL'] user_real_name = UserDatabaseOPS.select_user_name_surname( user.username) if user_real_name == -1: UserDatabaseOPS.add_real_name(user.username, my_name, my_surname) else: UserDatabaseOPS.update_real_name(user.username, my_name, my_surname) UserDatabaseOPS.update_user(user.username, user.password, user.profile_pic, user.cover_pic, user.mail_address) user_real_name = UserDatabaseOPS.select_user_name_surname( user.username) if 'deleteReal' in request.form: user = UserDatabaseOPS.select_user_with_id(user_id) UserDatabaseOPS.delete_real_name(user.username) user_real_name = UserDatabaseOPS.select_user_name_surname( user.username) return render_template('user_profile.html', signedin=True, user=user, real_name=user_real_name)
def settings_page(user_id): if request.method == 'GET': user = UserDatabaseOPS.select_user_with_id(user_id) real_name = UserDatabaseOPS.select_user_name_surname(user.username) return render_template('settings_page.html', signedin=True, user=user, real_name=real_name, error=False) else: mail = request.form['mail_address'] user = UserDatabaseOPS.select_user_with_id(user_id) real_name = UserDatabaseOPS.select_user_name_surname(user.username) UserDatabaseOPS.update_user(user.username, user.password, user.profile_pic, user.cover_pic, mail) changed_user = UserDatabaseOPS.select_user_with_id(user_id) return render_template('settings_page.html', signedin=True, user=changed_user, real_name=real_name, success=True)
def change_password_page(user_id): if request.method == 'GET': user = UserDatabaseOPS.select_user_with_id(user_id) real_name = UserDatabaseOPS.select_user_name_surname(user.username) return render_template('password_change.html', signedin=True, user=user, real_name=real_name, error=False) else: current_password = request.form['CurrentPassword'] new_password = request.form['NewPassword'] confirm_password = request.form['ConfirmPassword'] user = UserDatabaseOPS.select_user_with_id(user_id) real_name = UserDatabaseOPS.select_user_name_surname(user.username) user = UserDatabaseOPS.select_user_with_id(user_id) if current_password != user.password: return render_template('password_change.html', signedin=True, user=user, real_name=real_name, password_error=True) elif new_password != confirm_password: return render_template('password_change.html', signedin=True, user=user, real_name=real_name, password_match_error=True) else: UserDatabaseOPS.update_user(user.username, new_password, user.profile_pic, user.cover_pic, user.mail_address) return render_template('password_change.html', signedin=True, user=user, real_name=real_name, success=True)