diff --git a/progit/fork.py b/progit/fork.py index c83e6a9..c0ae027 100644 --- a/progit/fork.py +++ b/progit/fork.py @@ -414,6 +414,46 @@ def view_fork_issues(repo, username): ) +@APP.route('/fork///new_issue') +def fork_new_issue(username, repo): + """ Create a new issue + """ + repo = progit.lib.get_project(SESSION, repo, user=username) + + if repo is None: + flask.abort(404, 'Project not found') + + form = progit.forms.IssueForm() + if form.validate_on_submit(): + title = form.title.data + content = form.content.data + + try: + message = progit.lib.new_issue( + SESSION, + repo=repo, + title=title, + content=content, + user=flask.g.fas_user.username, + ) + SESSION.commit() + flask.flash(message) + return flask.redirect(flask.url_for( + 'view_fork_issues', username=username, repo=repo.name)) + except progit.exceptions.ProgitException, err: + flask.flash(str(err), 'error') + except SQLAlchemyError, err: # pragma: no cover + SESSION.rollback() + flask.flash(str(err), 'error') + + return flask.render_template( + 'new_issues.html', + select='issues', + form=form, + repo=repo, + ) + + @APP.route('/fork///request-pull') @APP.route('/fork///request-pull/') def request_pull_fork(username, repo, commitid=None):