Skip to content

Commit

Permalink
[scorecards] handle missing question groups
Browse files Browse the repository at this point in the history
Should never happen but file under 500 errors are bad
  • Loading branch information
struan committed Oct 24, 2023
1 parent b1ab820 commit d9a7aa9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,6 @@ def get_questions(self, context):
if council_type is not None:
comparison_questions = {}

council_group = PlanQuestionGroup.objects.get(
description=council_type["slug"]
)
context["council_type"] = council_type

council_count = Council.objects.filter(
Expand All @@ -597,9 +594,16 @@ def get_questions(self, context):
).count()
context["council_count"] = council_count

questions = PlanQuestion.objects.filter(
section=section, questiongroup=council_group
)
try:
council_group = PlanQuestionGroup.objects.get(
description=council_type["slug"]
)
questions = PlanQuestion.objects.filter(
section=section, questiongroup=council_group
)
except PlanQuestionGroup.DoesNotExist:
questions = PlanQuestion.objects.filter(section=section)

for question in questions:
comparison_questions[question.code] = {
"details": question,
Expand Down

0 comments on commit d9a7aa9

Please sign in to comment.