Add repo autocomplete for searching.

This commit is contained in:
Joseph Schorr 2013-09-27 19:21:54 -04:00
parent bf926aceee
commit edaad6eea2
6 changed files with 165 additions and 5 deletions

View file

@ -26,6 +26,9 @@ def get_user(username):
return None
def get_matching_users(username_prefix):
return list(User.select().where(User.username ** (username_prefix + '%')).limit(10))
def verify_user(username, password):
try:
fetched = User.get(User.username == username)
@ -58,6 +61,10 @@ def get_token(code):
return AccessToken.get(AccessToken.code == code)
def get_matching_repositories(repo_term):
return list(Repository.select().where(Repository.name ** ('%' + repo_term + '%') | Repository.namespace ** ('%' + repo_term + '%') | Repository.description ** ('%' + repo_term + '%')).limit(10))
def change_password(user, new_password):
pw_hash = bcrypt.hashpw(new_password, bcrypt.gensalt())
user.password_hash = pw_hash