Changeset f755aef in tailbone


Ignore:
Timestamp:
03/12/19 15:13:34 (6 months ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
7fab472
Parents:
4312238
Message:

Honor enum sort order where possible, for grid filter values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tailbone/grids/filters.py

    r4312238 rf755aef  
    33#
    44#  Rattail -- Retail Software Framework
    5 #  Copyright © 2010-2018 Lance Edgar
     5#  Copyright © 2010-2019 Lance Edgar
    66#
    77#  This file is part of Rattail.
     
    109109
    110110    def __init__(self, enum):
    111         sorted_keys = sorted(enum, key=lambda k: enum[k].lower())
     111        if isinstance(enum, OrderedDict):
     112            sorted_keys = list(enum.keys())
     113        else:
     114            sorted_keys = sorted(enum, key=lambda k: enum[k].lower())
    112115        self.options = [tags.Option(enum[k], six.text_type(k)) for k in sorted_keys]
    113116
Note: See TracChangeset for help on using the changeset viewer.