diff options
author | Dan McGee <dan@archlinux.org> | 2015-02-03 21:22:53 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2015-02-03 21:22:53 -0600 |
commit | ba6ae553c21374b1faf401712ac9d717e27ebe7d (patch) | |
tree | e273d5aed30fc194cf995ab1b11ef28a0e1266d8 | |
parent | a52b06c9c20475d6ba79a64239b17c5b4ffc44fe (diff) |
Sort packages correctly in the todolist notification emails
Just using sorted() here is bogus without a key function; the default
sort order is by the return value from id() in Python since we have no
__lt__ definition on the Package model. Add an explicit sort key.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | todolists/views.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/todolists/views.py b/todolists/views.py index c781a562..75c3d2d6 100644 --- a/todolists/views.py +++ b/todolists/views.py @@ -1,4 +1,5 @@ import json +from operator import attrgetter from django import forms from django.http import HttpResponse @@ -223,8 +224,9 @@ def send_todolist_emails(todo_list, new_packages): maint_packages.setdefault(maint, []).append(todo_package) for maint, packages in maint_packages.iteritems(): + packages = sorted(packages, key=attrgetter('pkgname', 'arch')) ctx = Context({ - 'todo_packages': sorted(packages), + 'todo_packages': packages, 'todolist': todo_list, }) template = loader.get_template('todolists/email_notification.txt') |