Change: treat created as date not datetime (#9793)

This commit is contained in:
shamoon
2025-05-16 07:23:04 -07:00
committed by GitHub
parent ce5d4e9c92
commit 1a6f32534c
18 changed files with 228 additions and 128 deletions

View File

@@ -48,6 +48,15 @@ CHAR_KWARGS = ["istartswith", "iendswith", "icontains", "iexact"]
ID_KWARGS = ["in", "exact"]
INT_KWARGS = ["exact", "gt", "gte", "lt", "lte", "isnull"]
DATE_KWARGS = [
"year",
"month",
"day",
"gt",
"gte",
"lt",
"lte",
]
DATETIME_KWARGS = [
"year",
"month",
"day",
@@ -731,6 +740,19 @@ class DocumentFilterSet(FilterSet):
mime_type = MimeTypeFilter()
# Backwards compatibility
created__date__gt = Filter(
field_name="created",
label="Created after",
lookup_expr="gt",
)
created__date__lt = Filter(
field_name="created",
label="Created before",
lookup_expr="lt",
)
class Meta:
model = Document
fields = {
@@ -739,8 +761,8 @@ class DocumentFilterSet(FilterSet):
"content": CHAR_KWARGS,
"archive_serial_number": INT_KWARGS,
"created": DATE_KWARGS,
"added": DATE_KWARGS,
"modified": DATE_KWARGS,
"added": DATETIME_KWARGS,
"modified": DATETIME_KWARGS,
"original_filename": CHAR_KWARGS,
"checksum": CHAR_KWARGS,
"correspondent": ["isnull"],
@@ -764,8 +786,8 @@ class ShareLinkFilterSet(FilterSet):
class Meta:
model = ShareLink
fields = {
"created": DATE_KWARGS,
"expiration": DATE_KWARGS,
"created": DATETIME_KWARGS,
"expiration": DATETIME_KWARGS,
}