From 4713b8ea2d71e3cb2164a5c2ac613dea4de8654e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 20 2015 09:49:53 +0000 Subject: Move checking if an issue has opened parent before closing into the internal API --- diff --git a/progit/lib/__init__.py b/progit/lib/__init__.py index 2a2fbdb..ca0df9c 100644 --- a/progit/lib/__init__.py +++ b/progit/lib/__init__.py @@ -523,6 +523,13 @@ def edit_issue(session, issue, ticketfolder, title=None, content=None, status=None, private=False): ''' Edit the specified issue. ''' + if status == 'Fixed' and issue.parents: + for parent in issue.parents: + if parent.status == 'Open': + raise progit.exceptions.ProgitException( + 'You cannot close a ticket that has ticket ' + 'depending that are still open.') + edit = [] if title and title != issue.title: issue.title = title diff --git a/progit/ui/issues.py b/progit/ui/issues.py index 9cf4ed1..f7de32d 100644 --- a/progit/ui/issues.py +++ b/progit/ui/issues.py @@ -118,17 +118,6 @@ def update_issue(repo, issueid, username=None): flask.flash(message) # Update status - if new_status == 'Fixed' and issue.parents: - for parent in issue.parents: - if parent.status == 'Open': - flask.flash( - 'You cannot close a ticket that has ticket ' - 'depending that are still open.', - 'error') - return flask.redirect(flask.url_for( - 'view_issue', repo=repo.name, username=username, - issueid=issueid)) - if new_status in status: message = progit.lib.edit_issue( SESSION, @@ -158,7 +147,7 @@ def update_issue(repo, issueid, username=None): except progit.exceptions.ProgitException, err: SESSION.rollback() - flask.flash(str(err), 'error') + flask.flash(err.message, 'error') except SQLAlchemyError, err: # pragma: no cover SESSION.rollback() APP.logger.exception(err)