From 49f39dbfa11eaf674eb6c50bbdf7ed2f7b34db20 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 20 2015 12:21:43 +0000 Subject: Prevent ticket that have opened parent to be closed We do not want to close ticket A if the ticket B that blocks ticket A is still open. Ticket B should be closed first, then ticket A can be closed. Note: we only apply this if the ticket is closed as 'Fixed'. Fixes http://209.132.184.222/progit/issue/40 --- diff --git a/progit/ui/issues.py b/progit/ui/issues.py index b29d877..9d18a90 100644 --- a/progit/ui/issues.py +++ b/progit/ui/issues.py @@ -419,11 +419,24 @@ def view_issue(repo, issueid, username=None): form_tag = progit.forms.AddIssueTagForm() if form.validate_on_submit(): + new_status = form.status.data + if new_status == 'Fixed' and issue.parents: + for parent in issue.parents: + print parent + 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)) + try: message = progit.lib.edit_issue( SESSION, issue=issue, - status=form.status.data, + status=new_status, ticketfolder=APP.config['TICKETS_FOLDER'], ) SESSION.commit()