Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AttributeError on speaker profile page #256

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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