From 56b3da60e234ac497b0a96656809d860375ecf15 Mon Sep 17 00:00:00 2001
From: Fredrik Jonsson <frjo@xdeb.org>
Date: Thu, 15 Aug 2019 11:59:33 +0200
Subject: [PATCH] Sort the transitions by the order they are listed.

---
 opentech/apply/funds/forms.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/opentech/apply/funds/forms.py b/opentech/apply/funds/forms.py
index 192dbfba3..91911a985 100644
--- a/opentech/apply/funds/forms.py
+++ b/opentech/apply/funds/forms.py
@@ -27,6 +27,9 @@ class ProgressSubmissionForm(forms.ModelForm):
         self.user = kwargs.pop('user')
         super().__init__(*args, **kwargs)
         choices = list(self.instance.get_actions_for_user(self.user))
+        # Sort the transitions by the order they are listed.
+        sort_by = list(self.instance.phase.transitions.keys())
+        choices.sort(key=lambda k: sort_by.index(k[0]))
         action_field = self.fields['action']
         action_field.choices = choices
         self.should_show = bool(choices)
-- 
GitLab