Skip to content

Commit

Permalink
updates message, fixes failure when passing empty edtf filter #10250
Browse files Browse the repository at this point in the history
  • Loading branch information
chrabyrd committed Nov 29, 2023
1 parent c9e1e0f commit 2daf796
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions arches/app/datatypes/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,16 @@ def add_date_to_doc(document, edtf):

def append_search_filters(self, value, node, query, request):
def add_date_to_doc(query, edtf):
invalid_filter_exception = Exception(
_(
'Only dates that specify an exact year, month, \
and day can be used with the "=", ">", "<", ">=", and "<=" operators'
)
)

if value["op"] == "eq":
if edtf.lower != edtf.upper:
raise Exception(_('Only dates that specify an exact year, month, and day can be used with the "=" operator'))
raise invalid_filter_exception
else:
operators = {"gte": edtf.lower, "lte": edtf.lower}
query.must(Range(field="tiles.data.%s.dates.date" % (str(node.pk)), **operators))
Expand All @@ -564,12 +571,7 @@ def add_date_to_doc(query, edtf):
operators = {"gte": edtf.lower, "lte": edtf.upper}
else:
if edtf.lower != edtf.upper:
raise Exception(
_(
'Only dates that specify an exact year, month, \
and day can be used with the ">", "<", ">=", and "<=" operators'
)
)
raise invalid_filter_exception

operators = {value["op"]: edtf.lower or edtf.upper}

Expand All @@ -582,7 +584,9 @@ def add_date_to_doc(query, edtf):
if edtf.lower is None and edtf.upper is None:
raise Exception(_("Invalid date specified."))

if value["op"] == "null" or value["op"] == "not_null":
if not value.get('op'):
pass
elif value["op"] == "null" or value["op"] == "not_null":
self.append_null_search_filters(value, node, query, request)
elif value["val"] != "" and value["val"] is not None:
edtf = ExtendedDateFormat(value["val"])
Expand Down

0 comments on commit 2daf796

Please sign in to comment.