Skip to content

Commit

Permalink
[scorecards] handle councils dissolved pre 2021 on 2021 scorecards
Browse files Browse the repository at this point in the history
  • Loading branch information
struan committed Oct 18, 2023
1 parent 875c1a5 commit 047fcef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
6 changes: 5 additions & 1 deletion scoring2022/templates/scoring2022/council.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ <h1 class="text-white mt-3">{{ council.name }}</h1>
<h3 class="mb-3">About this council</h3>
{% if new_council %}
<p>This council was created on April 1, 2023 so was not included in the 2021 Scorecards.</p>
{% elif old_council %}
<p>This council was disbanded before April 1, 2021 so was not included in the 2021 Scorecards.</p>
{% elif no_plan %}
<p>We do not currently have a Scorecard for this council.</p>
{% else %}
{% if plan_score.top_performer %}
<p class="top-performer.active mb-0">This council is a top performer within {% include 'caps/includes/authority_type.html' with group=authority_type %} councils.</p>
Expand Down Expand Up @@ -104,7 +108,7 @@ <h3 class="mb-3">About the scoring</h3>
</div>
</div>

{% if not new_council %}
{% if not new_council and not old_council and not no_plan %}
<div class="container council-page mt-4">
<div class="row">
<div class="col-md-12">
Expand Down
16 changes: 13 additions & 3 deletions scoring2022/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,32 @@ def get_context_data(self, **kwargs):
council = context.get("council")
group = council.get_scoring_group()

context["authority_type"] = group
new_council_date = date(year=2023, month=1, day=1)
if council.start_date is not None and council.start_date >= new_council_date:
context["authority_type"] = group
context["new_council"] = True
return context

old_council_date = date(year=2021, month=4, day=1)
if council.end_date is not None and council.end_date <= old_council_date:
context["authority_type"] = group
context["old_council"] = True
return context

context["all_councils"] = Council.objects.filter(
authority_type__in=group["types"],
country__in=group["countries"],
# newer councils don't have a score so don't include them
start_date__lt="2023-01-01",
)

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

promises = Promise.objects.filter(council=council).all()
plan_score = PlanScore.objects.get(council=council, year=2021)
plan_urls = PlanScoreDocument.objects.filter(plan_score=plan_score)
sections = PlanSectionScore.sections_for_council(
council=council, plan_year=2021
Expand Down Expand Up @@ -283,7 +294,6 @@ def get_context_data(self, **kwargs):

context["council_count"] = council_count
context["targets"] = promises
context["authority_type"] = group
context["plan_score"] = plan_score
context["plan_urls"] = plan_urls
context["sections"] = sorted(
Expand Down

0 comments on commit 047fcef

Please sign in to comment.