Skip to content

Adjust assessment check #3836

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

Merged
merged 1 commit into from
Mar 25, 2025
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
9 changes: 6 additions & 3 deletions econplayground/main/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.test import TestCase, RequestFactory
from django.urls import reverse
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.messages import get_messages
from econplayground.main.views import MyLTILandingPage, CohortCreateView
from econplayground.main.tests.factories import (
Expand Down Expand Up @@ -59,8 +58,12 @@ def test_get_no_assessment(self):
g.assessment.delete()
g.assessment = None
g.save()
with self.assertRaises(ObjectDoesNotExist):
self.client.get(reverse('graph_detail', kwargs={'pk': g.pk}))

r = self.client.get(reverse('graph_detail', kwargs={'pk': g.pk}))

self.assertEqual(r.status_code, 200)
self.assertContains(r, g.title)
self.assertContains(r, g.topic.cohort.title)


class GraphPickViewTest(LoggedInTestInstructorMixin, TestCase):
Expand Down
3 changes: 2 additions & 1 deletion econplayground/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ def get_context_data(self, *args, **kwargs):
ctx = super(GraphDetailView, self).get_context_data(*args, **kwargs)

assessment_change_url = None
if self.object.assessment and user_is_instructor(self.request.user):
if hasattr(self.object, 'assessment') and self.object.assessment and \
user_is_instructor(self.request.user):
assessment_change_url = reverse(
'admin:main_assessment_change',
kwargs={'object_id': self.object.assessment.pk})
Expand Down
Loading