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

Proposed by Nigel Babu
Status: Merged
Approved by: j.c.sackett
Approved revision: no longer in the source branch.
Merged at revision: 13094
Proposed branch: lp:~nigelbabu/launchpad/203478-meeting-sort
Merge into: lp:launchpad
Diff against target: 58 lines (+29/-2)
3 files modified
lib/lp/blueprints/model/sprint.py (+1/-1)
lib/lp/blueprints/model/tests/test_sprint.py (+27/-0)
lib/lp/blueprints/stories/sprints/20-sprint-registration.txt (+1/-1)
To merge this branch: bzr merge lp:~nigelbabu/launchpad/203478-meeting-sort
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+61623@code.launchpad.net

Commit message

[r=jcsackett][bug=203478] Sorts the list of attendees for a sprint by displayname, rather than the name attribute.

Description of the change

Sort the list of attendees for a sprint or meeting by displayname instead of name.

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

This looks fine.

It might make a little more sense to have your test check displayname rather than name, since that was the condition you were ordering on. e.g.

+ attendances = [bob.displayname, dave.displayname]
+ people = [attendee.attendee.displayname for attendee in sprint.attendances]
+ self.assertEqual(attendances, people)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/blueprints/model/sprint.py'
2--- lib/lp/blueprints/model/sprint.py 2011-03-18 04:18:01 +0000
3+++ lib/lp/blueprints/model/sprint.py 2011-05-19 22:29:29 +0000
4@@ -314,7 +314,7 @@
5 # result set. Listification should do.
6 list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(
7 people, need_validity=True))
8- return sorted(result, key=lambda a: a.attendee.name)
9+ return sorted(result, key=lambda a: a.attendee.displayname)
10
11 # linking to specifications
12 def linkSpecification(self, spec):
13
14=== added file 'lib/lp/blueprints/model/tests/test_sprint.py'
15--- lib/lp/blueprints/model/tests/test_sprint.py 1970-01-01 00:00:00 +0000
16+++ lib/lp/blueprints/model/tests/test_sprint.py 2011-05-19 22:29:29 +0000
17@@ -0,0 +1,27 @@
18+# Copyright 2011 Canonical Ltd. This software is licensed under the
19+# GNU Affero General Public License version 3 (see the file LICENSE).
20+
21+"""Unit test for sprints."""
22+
23+__metaclass__ = type
24+
25+from canonical.testing.layers import DatabaseFunctionalLayer
26+from lp.testing import TestCaseWithFactory
27+
28+
29+class TestSprintAttendancesSort(TestCaseWithFactory):
30+
31+ layer = DatabaseFunctionalLayer
32+
33+ def test_attendances(self):
34+ #Test the sorting of attendances to be by displayname rather than name
35+ sprint = self.factory.makeSprint()
36+ bob = self.factory.makePerson(name='zbob', displayname='Bob')
37+ dave = self.factory.makePerson(name='wdave', displayname='Dave')
38+ sprint.attend(
39+ bob, sprint.time_starts, sprint.time_ends, True)
40+ sprint.attend(
41+ dave, sprint.time_starts, sprint.time_ends, True)
42+ attendances = [bob.displayname, dave.displayname]
43+ people = [attendee.attendee.displayname for attendee in sprint.attendances]
44+ self.assertEqual(attendances, people)
45
46=== modified file 'lib/lp/blueprints/stories/sprints/20-sprint-registration.txt'
47--- lib/lp/blueprints/stories/sprints/20-sprint-registration.txt 2010-10-18 22:24:59 +0000
48+++ lib/lp/blueprints/stories/sprints/20-sprint-registration.txt 2011-05-19 22:29:29 +0000
49@@ -147,8 +147,8 @@
50
51 >>> print_attendees(browser.contents)
52 Carlos Perelló Marín
53- Sample Person
54 Guilherme Salgado
55+ Sample Person
56
57 In order to make it easy to organize a meeting, we provide a facility
58 for exporting the list of attendees in CSV format to registered users,