Skip to content

Commit

Permalink
Fix selected_filters KeyErrrors
Browse files Browse the repository at this point in the history
  • Loading branch information
dalecannon committed Mar 22, 2024
1 parent 33c0220 commit 34b0846
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions measures/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
from measures.parsers import DutySentenceParser
from measures.patterns import MeasureCreationPattern
from measures.util import diff_components
from quotas.models import QuotaOrderNumber
from regulations.models import Regulation
from workbaskets.forms import SelectableObjectsForm
from workbaskets.models import WorkBasket
Expand Down Expand Up @@ -218,16 +217,12 @@ def selected_filter_formatter(self) -> List[List[str]]:
)

if "order_number" in selected_filters:
quota = QuotaOrderNumber.objects.current().get(
id=selected_filters["order_number"],
)
selected_filters_strings.append(
f"Quota Order Number {quota.structure_code}",
f"Quota Order Number {selected_filters['order_number']}",
)

if "sid" in selected_filters:
measure = models.Measure.objects.current().get(sid=selected_filters["sid"])
selected_filters_strings.append(f"ID {measure.sid}")
selected_filters_strings.append(f"ID {selected_filters['sid']}")

if "additional_code" in selected_filters:
code = AdditionalCode.objects.current().get(
Expand Down Expand Up @@ -267,7 +262,10 @@ def selected_filter_formatter(self) -> List[List[str]]:
footnote = Footnote.objects.current().get(id=selected_filters["footnote"])
selected_filters_strings.append(f"Footnote {footnote.structure_code}")

if "start_date_0" and "start_date_1" and "start_date_2" in selected_filters:
if all(
sf in selected_filters
for sf in ("start_date_0", "start_date_1", "start_date_1")
):
if selected_filters["start_date_modifier"] == "exact":
modifier = ""
else:
Expand All @@ -276,7 +274,9 @@ def selected_filter_formatter(self) -> List[List[str]]:
f"Start date: {modifier} {selected_filters['start_date_0']}/{selected_filters['start_date_1']}/{selected_filters['start_date_2']}",
)

if "end_date_0" and "end_date_1" and "end_date_2" in selected_filters:
if all(
sf in selected_filters for sf in ("end_date_0", "end_date_1", "end_date_2")
):
if selected_filters["end_date_modifier"] == "exact":
modifier = ""
else:
Expand Down

0 comments on commit 34b0846

Please sign in to comment.