Honor enum sort order where possible, for grid filter values

This commit is contained in:
Lance Edgar 2019-03-12 15:13:34 -05:00
parent 43122381f5
commit f755aefbfa

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2018 Lance Edgar # Copyright © 2010-2019 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -108,6 +108,9 @@ class EnumValueRenderer(ChoiceValueRenderer):
""" """
def __init__(self, enum): def __init__(self, enum):
if isinstance(enum, OrderedDict):
sorted_keys = list(enum.keys())
else:
sorted_keys = sorted(enum, key=lambda k: enum[k].lower()) sorted_keys = sorted(enum, key=lambda k: enum[k].lower())
self.options = [tags.Option(enum[k], six.text_type(k)) for k in sorted_keys] self.options = [tags.Option(enum[k], six.text_type(k)) for k in sorted_keys]