Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ workflows:
requires:
- "CDK Synth"
context: [deployment-development-ee, slack-secrets]
filters: { branches: { only: [ development ] } }
filters: { branches: { only: [ development, "form-tools20251015" ] } }
dc-environment: development
- code_deploy:
name: "Development: AWS CodeDeploy"
requires:
- "Development: CDK Deploy"
context: [deployment-development-ee, slack-secrets]
filters: { branches: { only: [ development ] } }
filters: { branches: { only: [ development, "form-tools20251015" ] } }
dc-environment: development
- cdk_deploy:
name: "Staging: CDK Deploy"
Expand Down
57 changes: 40 additions & 17 deletions every_election/apps/elections/views/id_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from django import forms
from django.db import transaction
from django.http import HttpResponseRedirect
from django.utils.functional import cached_property
from election_snooper.helpers import post_to_slack
from election_snooper.models import SnoopedElection
from elections.baker import send_event
Expand Down Expand Up @@ -122,38 +121,62 @@ def should_show_by_elections_source(wizard):


class IDCreatorWizard(NamedUrlSessionWizardView):
def __init__(self, *args, **kwargs):
self.cache = {}
return super().__init__(*args, **kwargs)

def get_template_names(self):
return [TEMPLATES[self.steps.current]]

@cached_property
@property
def get_election_type(self):
if self.get_cleaned_data_for_step("election_type"):
return self.get_cleaned_data_for_step("election_type").get(
"election_type"
)
return None
if "election_type" in self.cache:
return self.cache["election_type"]

cleaned_data = self.get_cleaned_data_for_step("election_type")
if cleaned_data:
self.cache["election_type"] = cleaned_data.get("election_type")

return self.cache.get("election_type")

@cached_property
@property
def get_election_subtypes(self):
if self.get_cleaned_data_for_step("election_subtype"):
return self.get_cleaned_data_for_step("election_subtype").get(
if "election_subtypes" in self.cache:
return self.cache["election_subtypes"]

if not self.condition_dict["election_subtype"](self):
return None

cleaned_data = self.get_cleaned_data_for_step("election_subtype")
if cleaned_data:
self.cache["election_subtypes"] = cleaned_data.get(
"election_subtype"
)
return None

@cached_property
return self.cache.get("election_subtypes")

@property
def get_organisations(self):
if self.get_cleaned_data_for_step("election_organisation"):
return self.get_cleaned_data_for_step("election_organisation").get(
"election_organisation"
)
if "election_organisation" in self.storage.extra_data:
return Organisation.objects.filter(
electedrole__election_type__election_type__in=self.storage.extra_data[
"election_organisation"
]
)
return None

if not self.condition_dict["election_organisation"](self):
return None

if "organisations" in self.cache:
return self.cache["organisations"]

cleaned_data = self.get_cleaned_data_for_step("election_organisation")
if cleaned_data:
self.cache["organisations"] = cleaned_data.get(
"election_organisation"
)

return self.cache.get("organisations")

def get_election_date(self):
election_date = self.get_cleaned_data_for_step("date") or {}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"django-cors-headers==4.7.0",
"django-extensions==3.2.3",
"django-filter==24.3",
"django-formtools==2.3",
"django-formtools==2.5.1",
"django-localflavor==4.0",
"django-middleware-global-request==0.3.5",
"django-model-utils==5.0.0",
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.