def __call__(self, form, field): object = session.query(self.model).filter( func.lower(self.field) == func.lower(field.data)).first() if object: raise ValidationError(self.message)
def getUserByEmail(email): try: user = session.query(User).filter_by(email=email).one() return user except: return None
def getUserItems(user_id): ''' Returns all items of an user, given it's id ''' items = session.query(Item).filter_by(user_id=user_id).all() return items
def getUserInfo(user_id): ''' Returns an user object, given it's id ''' user = session.query(User).get(user_id) return user
def getItemInfo(item_id): ''' Returns an item object, given it's id ''' item = session.query(Item).get(item_id) return item
def getAllCategories(): ''' Returns all categories ''' categories = session.query(Category).all() return categories
def getCategoryInfo(category_id): ''' Returns the category object given it's id ''' category = session.query(Category).get(category_id) return category
def showUser(user_id): user = session.query(User).filter_by(id=user_id).one() return render_template('user.html', user=user)