Fixed agenda_item.is_active_slide() with related item and list of speakers

This commit is contained in:
Oskar Hahn 2014-01-12 12:48:38 +01:00
parent 558bef2e91
commit bbd7542341
2 changed files with 14 additions and 4 deletions

View File

@ -272,13 +272,15 @@ class Item(SlideMixin, MPTTModel):
def is_active_slide(self): def is_active_slide(self):
""" """
Returns True if the slide is True. If the slide is a related item, Returns True if the slide is active. If the slide is a related item,
Returns True if the related object is active. Returns True if the related object is active.
""" """
if self.content_object and isinstance(self.content_object, SlideMixin): if super(Item, self).is_active_slide():
value = True
elif self.content_object and isinstance(self.content_object, SlideMixin):
value = self.content_object.is_active_slide() value = self.content_object.is_active_slide()
else: else:
value = super(Item, self).is_active_slide() value = False
return value return value

View File

@ -97,7 +97,15 @@ class ItemTest(TestCase):
The agenda item has to be active, if its related item is. The agenda item has to be active, if its related item is.
""" """
set_active_slide('test_related_item', pk=1) set_active_slide('test_related_item', pk=1)
self.assertTrue(self.item5.is_active_slide) self.assertTrue(self.item5.is_active_slide())
def test_is_active_related_item_list_of_speakers(self):
"""
Test the method 'is_active_slide' if the item is related but the list
of speakers is shown on the projector.
"""
set_active_slide('agenda', type='list_of_speakers', pk=5)
self.assertTrue(self.item5.is_active_slide())
def test_bad_related_item(self): def test_bad_related_item(self):
bad = BadRelatedItem.objects.create(name='dhfne94irkgl2047fzvb') bad = BadRelatedItem.objects.create(name='dhfne94irkgl2047fzvb')