def test_gothrough(self): services = dbsession.query(Customerservice).all() for s in services: print(s.service_id) print(s.MN_id) services = dbsession.query(Customerservice).filter( Customerservice.MN_id == '914403005990821317042201').all() for s in services: print(s.service_id) print(s.MN_id)
def check_login(url, username, password): user = dbsession.query(User).filter_by(wp_username=username).one() if not check_password_hash(user.wp_password, password): return render_template('error/401.html') else: try: return wp(url, username, password) except: return wp(url, username, password, transport=SpecialTransport())
def upload_new_packages(self, packages: np.ndarray) -> None: for i in range(0, packages.size): [name, repo] = self.get_package_info(packages[i]) item: Package = dbsession.query(Package).filter( Package.name_id == name).first() if item is None: dbsession.add(Package(name_id=name, repository=repo)) else: if item.repository != repo: item.repository = repo dbsession.commit()
def delete_user(user_id): if 'user' not in login_session: return redirect(url_for('index')) user = dbsession.query(User).filter_by(id=user_id).one() if request.method == 'POST': dbsession.delete(user) dbsession.commit() # Does this make sense? logout(user.id) flash('User deleted successfully') return redirect(url_for('index')) return render_template('users/deleteprofile.html')
def edit_user(user_id): if 'user' not in login_session: return redirect(url_for('index')) user = dbsession.query(User).filter_by(id=user_id).one() form = EditForm() if request.method == 'POST': user.id = user_id user.wp_username = form.wp_username.data user.wp_password = user.set_password_hash(form.wp_password.data) user.wp_url = form.wp_url.data dbsession.add(user) dbsession.commit() flash('User info edited successfully') return redirect(url_for('user_profile', user_id=user_id)) return render_template('users/editprofile.html')
def login(): #if login_session['logged_in'] is not None and login_session['logged_in'] == True: # return redirect(url_for('get_posts')) form = LoginForm() if form.validate_on_submit(): user = dbsession.query(User).filter_by( wp_username=form.wp_username.data).first() if user is None or not user.check_password(form.wp_password.data): flash('Invalid login') return redirect(url_for('login')) login_user(user, remember=form.remember_me.data) check_login(user.wp_url, user.wp_username, form.wp_password.data) login_session['logged_in'] = True login_session['pw'] = form.wp_password.data return redirect(url_for('get_posts')) return render_template('users/login.html', title='Log In', form=form)
def delete_row(self, id) -> bool: tag = dbsession.query(Tag).filter(Tag.name_id == id).first() if (tag == None): return False dbsession.delete(tag) dbsession.commit()
def get_users(): """Returns list of users""" result = dbsession.query(User).all() if result is None: return jsonify({'result': []}) return jsonify({'result': [r.to_dict() for r in result]})
def get_url(username): user = dbsession.query(User).filter_by(wp_username=username).first() return user.wp_url
def load_user(user_id): return dbsession.query(User).filter_by(id=user_id).first()
def user_profile(user_id): user = dbsession.query(User).filter_by(id=user_id).one() return render_template('users/user.html', user=user)