Commit b51d7e99 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

utils: Order case-insensitively

We were testing for that, but yet we haven't expressed it in the code,
relying on the default behavior of the database. This broke sqlite
compatibility.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 5053ed6f
......@@ -21,6 +21,7 @@ from __future__ import absolute_import
import datetime
import itertools
import six
from django.conf import settings
from django.contrib.auth.models import User
......@@ -29,6 +30,7 @@ from django.core.mail import EmailMessage
from django.db.models import Max, Q, F
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
from django.db.models.functions import Lower
from patchwork.models import (Bundle, BundlePatch, PatchChangeNotification,
EmailOptout, EmailConfirmation)
......@@ -53,10 +55,10 @@ def get_patch_ids(d, prefix='patch_id'):
class Order(object):
order_map = {
'date': 'date',
'name': 'name',
'name': Lower('name'),
'state': 'state__ordering',
'submitter': 'submitter__name',
'delegate': 'delegate__username',
'submitter': Lower('submitter__name'),
'delegate': Lower('delegate__username'),
}
default_order = ('date', True)
......@@ -104,8 +106,12 @@ class Order(object):
def apply(self, qs):
q = self.order_map[self.order]
if self.reversed:
q = '-' + q
if isinstance(q, six.string_types):
q = '-' + q
else:
q = q.desc()
orders = [q]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment