Skip to content

Commit

Permalink
Merge pull request #256 from jandd/multi-speaker-support
Browse files Browse the repository at this point in the history
Fix AttributeError on speaker profile page
  • Loading branch information
jandd authored Mar 23, 2020
2 parents 508f641 + 0e4d0af commit 65e8f89
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion devday/speaker/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from speaker.models import PublishedSpeaker, Speaker
from speaker.tests import speaker_testutils
from speaker.tests.speaker_testutils import TemporaryMediaTestCase
from talk.models import Talk, Track, TalkPublishedSpeaker
from talk.models import Talk, TalkPublishedSpeaker, Track


class TestCreateSpeakerView(TestCase):
Expand Down Expand Up @@ -110,6 +110,22 @@ def test_context_has_speaker(self):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["speaker"], self.speaker)

def test_talk_on_speaker_profile(self):
event = event_testutils.create_test_event()
talk = Talk.objects.create(
draft_speaker=self.speaker,
title="Test Talk",
abstract="Test abstract",
remarks="",
event=event,
)
self.client.login(username=self.email, password=self.password)
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["speaker"], self.speaker)
self.assertIn("sessions", response.context)
self.assertIn(talk, response.context["sessions"])


class TestUserSpeakerPortraitUploadView(TemporaryMediaTestCase):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion devday/speaker/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_context_data(self, **kwargs):
).order_by("start_time"),
"sessions": Talk.objects.filter(draft_speakers=context["speaker"])
.select_related("event")
.prefetch_related("draft_speaker", "published_speaker")
.prefetch_related("draft_speakers", "published_speakers")
.order_by("-event__title", "title"),
"speaker_image_height": settings.TALK_PUBLIC_SPEAKER_IMAGE_HEIGHT,
"speaker_image_width": settings.TALK_PUBLIC_SPEAKER_IMAGE_WIDTH,
Expand Down

0 comments on commit 65e8f89

Please sign in to comment.