Sort letter brandings alphabetically

Currently the brandings have non-deterministic sorting, which means
the order changes from page load to page load. This makes it hard to
find the item you’re looking for.

This commit sorts them by the name of the branding, same as for email
brandings.
This commit is contained in:
Chris Hill-Scott
2018-11-05 13:31:02 +00:00
parent 684d4f7782
commit 65cc6adabf
3 changed files with 21 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import weakref
from datetime import datetime, timedelta
from itertools import chain
from operator import itemgetter
import pytz
from flask_wtf import FlaskForm as Form
@@ -785,7 +786,10 @@ class LetterBranding(StripWhitespaceForm):
def __init__(self, choices=[], *args, **kwargs):
super().__init__(*args, **kwargs)
self.dvla_org_id.choices = choices
self.dvla_org_id.choices = list(sorted(
choices,
key=itemgetter(1),
))
dvla_org_id = RadioField(
'Which logo should this services letter have?',