Skip to content

Commit

Permalink
[scorecards] allow different default plan and methodology years
Browse files Browse the repository at this point in the history
There are points when we want to display the next year's scorecards
methodology as the default rather than the cuurent years to add a
METHODLOGY_YEAR setting and use that in place of the PLAN_YEAR if we're
not viewing a specific year.
  • Loading branch information
struan committed May 28, 2024
1 parent 2400e99 commit 8f94c01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions proj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
RELATED_SEARCH_THRESHOLD_LOOSE = 0.5

PLAN_YEAR = 2023
METHODOLOGY_YEAR = 2025

PLAN_SCORECARD_DATASET_DETAILS = {
"org": "mysociety",
Expand Down
2 changes: 1 addition & 1 deletion scoring/templates/scoring/methodology.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="methodology-2023-content js-dynamic-content ">
<div class="pt-5 pb-6 pt-lg-8 pb-lg-8 hero-section with-version-background">
<div class="d-flex flex-column align-items-end align-items-lg-start hero-version-badge position-absolute">
<span class="version-year d-block fw-bold lh-1">2023</span>
<span class="version-year d-block fw-bold lh-1">{{ methodology_year }}</span>
<span class="version-name d-block fw-bold lh-1">Action Scorecards</span>
</div>
<div class="container">
Expand Down
11 changes: 8 additions & 3 deletions scoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,15 +914,20 @@ def get_context_data(self, **kwargs):
context["page_title"] = "Methodology"
context["current_page"] = "methodology-page"

methodology_year = self.request.year
if kwargs.get("year") is None:
methodology_year = settings.METHODOLOGY_YEAR

context["methodology_year"] = methodology_year
context[
"intro_template"
] = f"scoring/methodology/{self.request.year}/_intro.html"
] = f"scoring/methodology/{methodology_year}/_intro.html"
context[
"details_template"
] = f"scoring/methodology/{self.request.year}/_details.html"
] = f"scoring/methodology/{methodology_year}/_details.html"

questions = (
PlanQuestion.objects.filter(section__year=self.request.year)
PlanQuestion.objects.filter(section__year=methodology_year)
.select_related("section")
.order_by("section__code", "code")
)
Expand Down

0 comments on commit 8f94c01

Please sign in to comment.