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
# Copyright © 2010-2018 Lance Edgar
# Copyright © 2010-2019 Lance Edgar
#
# This file is part of Rattail.
#
@ -108,7 +108,10 @@ class EnumValueRenderer(ChoiceValueRenderer):
"""
def __init__(self, enum):
sorted_keys = sorted(enum, key=lambda k: enum[k].lower())
if isinstance(enum, OrderedDict):
sorted_keys = list(enum.keys())
else:
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]