Skip to content

Commit

Permalink
Wraps the check for a course page and certificate page in a try/excep…
Browse files Browse the repository at this point in the history
…t so it doesn't fail if there's no course page for the courserun enrollment
  • Loading branch information
jkachel committed Sep 2, 2022
1 parent 18d212a commit eb6f6a5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions courses/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,14 @@ def get_certificate(self, enrollment):

# No need to include a certificate if there is no corresponding wagtail page
# to support the render
if (
not enrollment
or not enrollment.run.course.page
or not enrollment.run.course.page.certificate_page
):
try:
if (
not enrollment
or not enrollment.run.course.page
or not enrollment.run.course.page.certificate_page
):
return None
except models.Course.page.RelatedObjectDoesNotExist:
return None

# Using IDs because we don't need the actual record and this avoids redundant queries
Expand Down

0 comments on commit eb6f6a5

Please sign in to comment.