Skip to content

Commit

Permalink
Merge pull request #5533 from fecgov/fix-legal-dates
Browse files Browse the repository at this point in the history
add legal date formats
  • Loading branch information
cnlucas authored Aug 7, 2023
2 parents 1e56b9a + a6521e4 commit 4740690
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions webservices/resources/legal.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"admin_fines",
]

ACCEPTED_DATE_FORMATS = "strict_date_optional_time_nanos||MM/dd/yyyy||M/d/yyyy||MM/d/yyyy||M/dd/yyyy"

# endpoint path: /legal/docs/<doc_type>/<no>
# test urls:
Expand All @@ -56,6 +57,7 @@
# http://127.0.0.1:5000/v1/legal/docs/adrs/1091/
# http://127.0.0.1:5000/v1/legal/docs/admin_fines/4399/


# TODO: add this endpoint to swagger
@doc(
tags=["legal"],
Expand Down Expand Up @@ -270,6 +272,7 @@ def apply_af_specific_query_params(query, **kwargs):
if kwargs.get("af_max_rtb_date"):
date_range["lte"] = kwargs.get("af_max_rtb_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", reason_to_believe_action_date=date_range))

date_range = {}
Expand All @@ -278,6 +281,7 @@ def apply_af_specific_query_params(query, **kwargs):
if kwargs.get("af_max_fd_date"):
date_range["lte"] = kwargs.get("af_max_fd_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", final_determination_date=date_range))

if kwargs.get("af_rtb_fine_amount"):
Expand Down Expand Up @@ -319,6 +323,7 @@ def apply_mur_specific_query_params(query, **kwargs):
if kwargs.get("case_max_open_date"):
date_range["lte"] = kwargs.get("case_max_open_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", open_date=date_range))

date_range = {}
Expand All @@ -327,6 +332,7 @@ def apply_mur_specific_query_params(query, **kwargs):
if kwargs.get("case_max_close_date"):
date_range["lte"] = kwargs.get("case_max_close_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", close_date=date_range))

query = query.query("bool", must=must_clauses)
Expand Down Expand Up @@ -453,6 +459,7 @@ def apply_adr_specific_query_params(query, **kwargs):
if kwargs.get("case_max_open_date"):
date_range["lte"] = kwargs.get("case_max_open_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", open_date=date_range))

date_range = {}
Expand All @@ -461,6 +468,7 @@ def apply_adr_specific_query_params(query, **kwargs):
if kwargs.get("case_max_close_date"):
date_range["lte"] = kwargs.get("case_max_close_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", close_date=date_range))

query = query.query("bool", must=must_clauses)
Expand Down Expand Up @@ -645,6 +653,7 @@ def apply_ao_specific_query_params(query, **kwargs):
if kwargs.get("ao_max_issue_date"):
date_range["lte"] = kwargs.get("ao_max_issue_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", issue_date=date_range))

date_range = {}
Expand All @@ -653,6 +662,7 @@ def apply_ao_specific_query_params(query, **kwargs):
if kwargs.get("ao_max_request_date"):
date_range["lte"] = kwargs.get("ao_max_request_date")
if date_range:
date_range["format"] = ACCEPTED_DATE_FORMATS
must_clauses.append(Q("range", request_date=date_range))

if kwargs.get("ao_entity_name"):
Expand Down

0 comments on commit 4740690

Please sign in to comment.