Project

General

Profile

0001-misc-change-sorting-on-category-formdef-role-names-i.patch

Frédéric Péters, 21 Nov 2018 11:01 AM

Download (2.57 KB)

View differences:

Subject: [PATCH] misc: change sorting on category/formdef/role names ignore
 accents (#28170)

 wcs/admin/categories.py | 3 +--
 wcs/admin/roles.py      | 3 +--
 wcs/qommon/storage.py   | 5 +++++
 3 files changed, 7 insertions(+), 4 deletions(-)
wcs/admin/categories.py
85 85
            r += self.category.get_description_html_text(editable=False)
86 86
            r += htmltext('</div>')
87 87

  
88
        formdefs = FormDef.select()
88
        formdefs = FormDef.select(order_by='name')
89 89
        formdefs = [x for x in formdefs if x.category_id == self.category.id]
90
        formdefs.sort(lambda x,y: cmp(x.name, y.name))
91 90
        r += htmltext('<div class="bo-block">')
92 91
        r += htmltext('<h3>%s</h3>') % _('Forms in this category')
93 92
        r += htmltext('<ul>')
wcs/admin/roles.py
121 121
        # list forms in two columns,
122 122
        #  - 1 forms where this role is affected by the workflow
123 123
        #  - 2 forms where the sender is this role
124
        formdefs = FormDef.select()
125
        formdefs.sort(lambda x,y: cmp(x.name, y.name))
124
        formdefs = FormDef.select(order_by='name')
126 125
        workflow_formdefs = [x for x in formdefs if x.is_of_concern_for_role_id(self.role.id)]
127 126
        sender_formdefs = [x for x in formdefs if self.role.id in (x.roles or [])]
128 127

  
wcs/qommon/storage.py
265 265
            objects = list(objects)
266 266
            if order_by == 'id':
267 267
                cmp_function = lambda x, y: cmp(lax_int(x.id), lax_int(y.id))
268
            elif order_by == 'name':
269
                # proper collation should be done but it's messy to get working
270
                # on all systems so we go the cheap and almost ok way.
271
                from .misc import simplify
272
                cmp_function = lambda x, y: cmp(simplify(x.name), simplify(y.name))
268 273
            else:
269 274
                cmp_function = lambda x, y: cmp(getattr(x, order_by), getattr(y, order_by))
270 275
            objects.sort(cmp_function)
271
-