Merge lp:~danilo/summit/fix-plenaries into lp:summit

Proposed by Данило Шеган on 2012-01-24
Status: Merged
Approved by: Michael Hall on 2012-01-24
Approved revision: 261
Merged at revision: 262
Proposed branch: lp:~danilo/summit/fix-plenaries
Merge into: lp:summit
Prerequisite: lp:~cjohnston/summit/920751
Diff against target: 36 lines (+7/-3)
2 files modified
summit/schedule/render.py (+5/-1)
summit/schedule/tests.py (+2/-2)
To merge this branch: bzr merge lp:~danilo/summit/fix-plenaries
Reviewer Review Type Date Requested Status
Michael Hall (community) 2012-01-24 Approve on 2012-01-24
Review via email: mp+89963@code.launchpad.net

Commit Message

Do not crash when multiple agendas are returned for the same time slot (eg. due to multiple plenary rooms).

Description of the Change

Do not crash if multiple agendas are returned for the same slot because of multiple plenary rooms. Alternatively, agenda_set could have been modified, but I decided for a quick and dirty fix atm.

This should allow some plenaries to be rendered, though the "algorithm" (i.e. return the first one returned from the DB) might not be the best one around.

There is also a chance that the test is not reliable since it depends on the order agenda_set.all() returns DB records, so it may intermittently fail. To fix that, we only need to ensure that the call passes without crashing and not check the return value.

To post a comment you must log in.
Michael Hall (mhall119) wrote :

Okay for now, we need to revisit how we handle multiple plenaries throughout the codebase though

review: Approve
Tarmac WebDev (tarmac-webdev) wrote :

The prerequisite lp:~chrisjohnston/summit/920751 has not yet been merged into lp:summit.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'summit/schedule/render.py'
2--- summit/schedule/render.py 2012-01-24 18:03:27 +0000
3+++ summit/schedule/render.py 2012-01-24 18:03:27 +0000
4@@ -223,7 +223,11 @@
5 # no matter what room we're looking at
6 if slot.type == 'plenary':
7 try:
8- agenda = slot.agenda_set.get()
9+ agendas = slot.agenda_set.all()
10+ if len(agendas) == 0:
11+ raise ObjectDoesNotExist
12+ else:
13+ agenda = agendas[0]
14 self.meetings[slot].append(
15 (agenda.room, agenda.meeting))
16 except ObjectDoesNotExist:
17
18=== modified file 'summit/schedule/tests.py'
19--- summit/schedule/tests.py 2012-01-24 04:30:40 +0000
20+++ summit/schedule/tests.py 2012-01-24 18:03:27 +0000
21@@ -1498,7 +1498,7 @@
22 schedule.calculate_unscheduled()
23 self.assertEqual([], schedule.unscheduled)
24
25- def test_calculate_includes_all_plenary_rooms_if_editing(self):
26+ def test_calculate_passes_with_multiple_plenary_rooms_if_editing(self):
27 now = datetime.datetime.utcnow()
28 one_hour = datetime.timedelta(hours=1)
29 summit = factory.make_one(
30@@ -1516,7 +1516,7 @@
31 # To avoid test being fragile and arbitrarily dependent on the
32 # room order, we check the returned schedule.meetings bit-by-bit.
33 self.assertEqual([slot], schedule.meetings.keys())
34- self.assertEqual(set([(room1, None), (room2, None)]),
35+ self.assertEqual(set([(room1, None)]),
36 set(schedule.meetings[slot]))
37
38

Subscribers

People subscribed via source and target branches