Skip to content

Commit

Permalink
Merge pull request #4488 from freelawproject/4487-fix-entry-date-file…
Browse files Browse the repository at this point in the history
…d-display-search-results

4487 Fixed entry_date_filed display on RECAP Search results
  • Loading branch information
albertisfu committed Sep 24, 2024
2 parents a7c7979 + c97bf57 commit 5f168d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 3 additions & 2 deletions cl/custom_filters/templatetags/extras.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import random
import re
from datetime import date, datetime
from datetime import datetime

from django import template
from django.core.exceptions import ValidationError
from django.template import Context
from django.template.defaultfilters import date as date_filter
from django.utils.formats import date_format
from django.utils.html import format_html
from django.utils.http import urlencode
Expand Down Expand Up @@ -282,7 +283,7 @@ def format_date(date_str: str) -> str:
ES child document results where dates are not date objects."""
try:
date_obj = datetime.strptime(date_str, "%Y-%m-%d")
return date_obj.strftime("%B %dth, %Y")
return date_filter(date_obj, "F jS, Y")
except (ValueError, TypeError):
return date_str

Expand Down
2 changes: 1 addition & 1 deletion cl/lib/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ def setUpTestData(cls):
source=Docket.COLUMBIA_AND_RECAP,
),
entry_number=3,
date_filed=datetime.date(2014, 7, 19),
date_filed=datetime.date(2014, 7, 5),
description="MOTION for Leave to File Amicus Discharging Debtor",
)
cls.rd_2 = RECAPDocumentFactory(
Expand Down
14 changes: 9 additions & 5 deletions cl/search/tests/tests_es_recap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2088,10 +2088,10 @@ def test_results_ordering(self) -> None:
0, r.content.decode(), 1, "August 19th, 2015"
)
self._compare_child_entry_date_filed(
1, r.content.decode(), 0, "July 19th, 2014"
1, r.content.decode(), 0, "July 5th, 2014"
)
self._compare_child_entry_date_filed(
2, r.content.decode(), 0, "February 23th, 1732"
2, r.content.decode(), 0, "February 23rd, 1732"
)

# Order by entry_date_filed asc
Expand All @@ -2116,10 +2116,10 @@ def test_results_ordering(self) -> None:

# Confirm entry date filed are properly displayed.
self._compare_child_entry_date_filed(
0, r.content.decode(), 0, "February 23th, 1732"
0, r.content.decode(), 0, "February 23rd, 1732"
)
self._compare_child_entry_date_filed(
1, r.content.decode(), 0, "July 19th, 2014"
1, r.content.decode(), 0, "July 5th, 2014"
)
self._compare_child_entry_date_filed(
2, r.content.decode(), 0, "August 19th, 2015"
Expand Down Expand Up @@ -2887,7 +2887,9 @@ def setUpTestData(cls):
cited_opinion=cls.opinion,
depth=1,
)
BankruptcyInformationFactory(docket=cls.de_api.docket)
BankruptcyInformationFactory(
docket=cls.de_api.docket, trustee_str="Lorem Ipsum"
)

cls.de_empty_fields_api = DocketEntryWithParentsFactory(
docket=DocketFactory(
Expand All @@ -2909,6 +2911,7 @@ def setUpTestData(cls):
court=cls.court_api,
date_argued=None,
source=Docket.RECAP_AND_IDB,
case_name_full="",
)

async def _test_api_results_count(
Expand Down Expand Up @@ -3825,6 +3828,7 @@ def test_date_filed_sorting_function_score(self) -> None:
docket_entry_recent = DocketEntryWithParentsFactory(
docket__source=Docket.RECAP,
docket__case_name="Lorem Ipsum",
docket__case_name_full="",
docket__date_filed=datetime.date(2024, 2, 23),
date_filed=datetime.date(2022, 2, 23),
)
Expand Down

0 comments on commit 5f168d2

Please sign in to comment.