projects
/
oweals
/
karmaworld.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b3d96c6
)
add sorting by length of School.name
330/head
author
Jacob Hilker
<hilker.j@gmail.com>
Tue, 11 Feb 2014 22:28:57 +0000
(17:28 -0500)
committer
Jacob Hilker
<hilker.j@gmail.com>
Tue, 11 Feb 2014 22:28:57 +0000
(17:28 -0500)
karmaworld/apps/courses/views.py
patch
|
blob
|
history
diff --git
a/karmaworld/apps/courses/views.py
b/karmaworld/apps/courses/views.py
index 7ef80ebf7e1685f774a5d17aedcd0d1197741eb7..42900f5ed9304a6e53f219cf6ced80e326705ccc 100644
(file)
--- a/
karmaworld/apps/courses/views.py
+++ b/
karmaworld/apps/courses/views.py
@@
-113,7
+113,7
@@
def school_list(request):
# get the schools as a id name dict,
_query = request.POST['q']
matching_school_aliases = list(School.objects.filter(alias__icontains=_query))
- matching_school_names =
list(School.objects.filter(name__icontains=_query)[:20]
)
+ matching_school_names =
sorted(list(School.objects.filter(name__icontains=_query)[:20]),key=lambda o:len(o.name)
)
_schools = matching_school_aliases[:2] + matching_school_names
schools = [{'id': s.id, 'name': s.name} for s in _schools]