Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TP2000-1044 Include geo areas with future start dates in dropdown lists #1028

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 17 additions & 0 deletions common/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ def test_as_at_today(model1_with_history):
}


def test_as_at_today_and_beyond(date_ranges, validity_factory):
"""Ensure only records active at the current date and future records are
fetched."""
outdated_record = {validity_factory.create(valid_between=date_ranges.earlier).pk}

active_and_future_records = {
validity_factory.create(valid_between=date_ranges.normal).pk,
validity_factory.create(valid_between=date_ranges.later).pk,
}

Model = validity_factory._meta.get_model_class()
a-gleeson marked this conversation as resolved.
Show resolved Hide resolved
queryset = set(Model.objects.as_at_today_and_beyond().values_list("pk", flat=True))

assert queryset != outdated_record
assert queryset == active_and_future_records


def test_get_version_raises_error():
"""Ensure that trying to get a specific version raises an error if no
identifiers given."""
Expand Down
18 changes: 9 additions & 9 deletions geo_areas/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, *args, **kwargs):
GeographicalArea.objects.filter(area_code=AreaCode.COUNTRY)
.current()
.with_latest_description()
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
dalecannon marked this conversation as resolved.
Show resolved Hide resolved
)
self.fields[
Expand All @@ -107,7 +107,7 @@ def __init__(self, *args, **kwargs):
GeographicalArea.objects.filter(area_code=AreaCode.REGION)
.current()
.with_latest_description()
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
)
self.fields[
Expand Down Expand Up @@ -196,7 +196,7 @@ def __init__(self, *args, **kwargs):
GeographicalArea.objects.filter(area_code=AreaCode.GROUP)
.current()
.with_latest_description()
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
)
self.fields[
Expand Down Expand Up @@ -542,7 +542,7 @@ def __init__(self, *args, **kwargs):
.exclude(pk__in=current_memberships)
.current()
.with_latest_description()
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
)
self.fields[
Expand Down Expand Up @@ -631,7 +631,7 @@ def __init__(self, *args, **kwargs):
)
.current()
.with_latest_description()
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
)
self.fields[
Expand Down Expand Up @@ -768,7 +768,7 @@ def __init__(self, *args, **kwargs):
self.fields["erga_omnes_exclusion"].queryset = (
GeographicalArea.objects.current()
.with_latest_description()
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
)
self.fields[
Expand Down Expand Up @@ -803,7 +803,7 @@ def __init__(self, *args, **kwargs):
GeographicalArea.objects.current()
.with_latest_description()
.filter(area_code=AreaCode.GROUP)
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
dalecannon marked this conversation as resolved.
Show resolved Hide resolved
)
# descriptions__description" should make this implicitly distinct()
Expand All @@ -830,7 +830,7 @@ def __init__(self, *args, **kwargs):
self.fields["geo_group_exclusion"].queryset = (
GeographicalArea.objects.current()
.with_latest_description()
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
)
self.fields[
Expand Down Expand Up @@ -879,7 +879,7 @@ def __init__(self, *args, **kwargs):
GeographicalArea.objects.current()
.with_latest_description()
.exclude(area_code=AreaCode.GROUP)
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
)

Expand Down
4 changes: 2 additions & 2 deletions quotas/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, *args, **kwargs):
self.fields["exclusion"].queryset = (
GeographicalArea.objects.current()
.with_latest_description()
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
)
self.fields[
Expand Down Expand Up @@ -258,7 +258,7 @@ def init_fields(self):
self.fields["geographical_area"].queryset = (
GeographicalArea.objects.current()
.with_latest_description()
.as_at_today()
.as_at_today_and_beyond()
.order_by("description")
)
self.fields[
Expand Down