From 7d23c041cb47229be346f18e3a52ba8c7b7ee1a9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 31 2014 10:40:44 +0000 Subject: Fix the new_pull_request method from the internal API to use the new user model Signed-off-by: Pierre-Yves Chibon --- diff --git a/progit/lib.py b/progit/lib.py index b1fd10a..3928168 100644 --- a/progit/lib.py +++ b/progit/lib.py @@ -153,13 +153,24 @@ def new_issue(session, repo, title, content, user): def new_pull_request( session, repo, repo_from, title, user, stop_id, start_id=None): ''' Create a new pull request on the specified repo. ''' + user_obj = session.query( + model.User + ).filter( + model.User.user == user + ).first() + + if not user_obj: + raise progit.exceptions.ProgitException( + 'No user "%s" found' % user + ) + request = model.PullRequest( project_id=repo.id, project_id_from=repo_from.id, title=title, start_id=start_id, stop_id=stop_id, - user=user, + user_id=user_obj.id, ) session.add(request) # Make sure we won't have SQLAlchemy error before we create the request