Skip to content

Commit

Permalink
[scorecards] fix 500 error on councils with no plan
Browse files Browse the repository at this point in the history
This is mostly the new councils that we didn't score
  • Loading branch information
struan committed Oct 18, 2023
1 parent 1d3bc67 commit 81b32e2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,6 @@ def get_context_data(self, **kwargs):
context["old_council"] = True
return context

try:
plan_score = PlanScore.objects.get(council=council, year=settings.PLAN_YEAR)
except PlanScore.DoesNotExist:
context["no_plan"] = True

promises = Promise.objects.filter(council=council).all()

target = None
Expand All @@ -283,6 +278,13 @@ def get_context_data(self, **kwargs):
target = promise
elif target is not None and promise.scope == PlanDocument.WHOLE_AREA:
target = promise
context["target"] = target

try:
plan_score = PlanScore.objects.get(council=council, year=settings.PLAN_YEAR)
except PlanScore.DoesNotExist:
context["no_plan"] = True
return context

plan_urls = PlanScoreDocument.objects.filter(plan_score=plan_score)
sections = PlanSectionScore.sections_for_council(
Expand Down Expand Up @@ -379,7 +381,6 @@ def get_context_data(self, **kwargs):
).count()

context["council_count"] = council_count
context["target"] = target
context["authority_type"] = group
context["plan_score"] = plan_score
context["plan_urls"] = plan_urls
Expand Down

0 comments on commit 81b32e2

Please sign in to comment.