def list_users(user_id=0): if user_id: try: users = list(Users.get(user_id)) except SQLObjectNotFound: flash("No user found by that ID") return render_template('list_users.html') else: users = list(Users.select()) return render_template('list_users.html', data={'users': users})
def __call__(self, form, field): cyphertext = generate_password(field.data) username = form.email.data if form.user_id.data: raise ValidationError(self.message) try: user = list(Users.select(AND(Users.q.email==username, Users.q.password==cyphertext)))[0] if not user.active: raise ValidationError(self.message) form.user_id.data = user.id except (SQLObjectNotFound, IndexError): raise ValidationError(self.message)