← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~nigelbabu/launchpad/203478-meeting-sort into lp:launchpad

 

Nigel Babu has proposed merging lp:~nigelbabu/launchpad/203478-meeting-sort into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~nigelbabu/launchpad/203478-meeting-sort/+merge/61623

Sort the list of attendees for a sprint or meeting by displayname instead of name. 
-- 
https://code.launchpad.net/~nigelbabu/launchpad/203478-meeting-sort/+merge/61623
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~nigelbabu/launchpad/203478-meeting-sort into lp:launchpad.
=== modified file 'lib/lp/blueprints/model/sprint.py'
--- lib/lp/blueprints/model/sprint.py	2011-03-18 04:18:01 +0000
+++ lib/lp/blueprints/model/sprint.py	2011-05-19 17:27:31 +0000
@@ -314,7 +314,7 @@
         # result set.  Listification should do.
         list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(
                 people, need_validity=True))
-        return sorted(result, key=lambda a: a.attendee.name)
+        return sorted(result, key=lambda a: a.attendee.displayname)
 
     # linking to specifications
     def linkSpecification(self, spec):

=== added file 'lib/lp/blueprints/model/tests/test_sprint.py'
--- lib/lp/blueprints/model/tests/test_sprint.py	1970-01-01 00:00:00 +0000
+++ lib/lp/blueprints/model/tests/test_sprint.py	2011-05-19 17:27:31 +0000
@@ -0,0 +1,27 @@
+# Copyright 2011 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Unit test for sprints."""
+
+__metaclass__ = type
+
+from canonical.testing.layers import DatabaseFunctionalLayer
+from lp.testing import TestCaseWithFactory
+
+
+class TestSprintAttendancesSort(TestCaseWithFactory):
+
+    layer = DatabaseFunctionalLayer
+
+    def test_attendances(self):
+        #Test the sorting of attendances to be by displayname rather than name
+        sprint = self.factory.makeSprint()
+        bob = self.factory.makePerson(name='zbob', displayname='Bob')
+        dave = self.factory.makePerson(name='wdave', displayname='Dave')
+        sprint.attend(
+            bob, sprint.time_starts, sprint.time_ends, True)
+        sprint.attend(
+            dave, sprint.time_starts, sprint.time_ends, True)
+        attendances = [bob.name, dave.name]
+        people = [attendee.attendee.name for attendee in sprint.attendances]
+        self.assertEqual(attendances, people)