From ba6ae553c21374b1faf401712ac9d717e27ebe7d Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 3 Feb 2015 21:22:53 -0600 Subject: 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 --- todolists/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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') -- cgit v1.2.3-54-g00ecf