Maintain patch status when moving to next CF
authorMagnus Hagander <magnus@hagander.net>
Wed, 2 Mar 2016 13:39:17 +0000 (14:39 +0100)
committerMagnus Hagander <magnus@hagander.net>
Wed, 2 Mar 2016 13:39:17 +0000 (14:39 +0100)
So a patch that's in "ready for committer" status remains there.

When doing this, also refuse to move any patches that are not either
"waiting for review" or "ready for committer". They will have to have
their existing status changed first, and then be moved.

pgcommitfest/commitfest/views.py

index ddd62c9b4bc1ffe7447a5fcc5cd9b20e8e50cb14..a6aee9c11a0c5a9b0c0554beee2ae23f59f35c73 100644 (file)
@@ -461,6 +461,24 @@ def close(request, cfid, patchid, status):
        elif status == 'feedback':
                poc.status = PatchOnCommitFest.STATUS_RETURNED
        elif status == 'next':
+               # Only some patch statuses can actually be moved.
+               if poc.status in (PatchOnCommitFest.STATUS_AUTHOR,
+                                                 PatchOnCommitFest.STATUS_COMMITTED,
+                                                 PatchOnCommitFest.STATUS_NEXT,
+                                                 PatchOnCommitFest.STATUS_RETURNED,
+                                                 PatchOnCommitFest.STATUS_REJECTED):
+                       # Can't be moved!
+                       messages.error(request, "A patch in status {0} cannot be moved to next commitfest.".format(poc.statusstring))
+                       return HttpResponseRedirect('/%s/%s/' % (poc.commitfest.id, poc.patch.id))
+               elif poc.status in (PatchOnCommitFest.STATUS_REVIEW,
+                                                       PatchOnCommitFest.STATUS_COMMITTER):
+                       # This one can be moved
+                       pass
+               else:
+                       messages.error(request, "Invalid existing patch status")
+
+               oldstatus = poc.status
+
                poc.status = PatchOnCommitFest.STATUS_NEXT
                # Figure out the commitfest to actually put it on
                newcf = CommitFest.objects.filter(status=CommitFest.STATUS_OPEN)
@@ -490,7 +508,10 @@ def close(request, cfid, patchid, status):
                                return HttpResponseRedirect('/%s/%s/' % (poc.commitfest.id, poc.patch.id))
                # Create a mapping to the new commitfest that we are bouncing
                # this patch to.
-               newpoc = PatchOnCommitFest(patch=poc.patch, commitfest=newcf[0], enterdate=datetime.now())
+               newpoc = PatchOnCommitFest(patch=poc.patch,
+                                                                  commitfest=newcf[0],
+                                                                  status=oldstatus,
+                                                                  enterdate=datetime.now())
                newpoc.save()
        elif status == 'committed':
                committer = get_object_or_404(Committer, user__username=request.GET['c'])