Convert value for more date filters; only add condition if valid

missed these in 187fea6d1b
This commit is contained in:
Lance Edgar 2022-09-06 13:09:14 -05:00
parent c43a4edec7
commit 365e4a4194

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -699,6 +699,30 @@ class AlchemyDateFilter(AlchemyGridFilter):
self.column != self.encode_value(date),
))
def filter_greater_than(self, query, value):
date = self.make_date(value)
if not date:
return query
return query.filter(self.column > self.encode_value(date))
def filter_greater_equal(self, query, value):
date = self.make_date(value)
if not date:
return query
return query.filter(self.column >= self.encode_value(date))
def filter_less_than(self, query, value):
date = self.make_date(value)
if not date:
return query
return query.filter(self.column < self.encode_value(date))
def filter_less_equal(self, query, value):
date = self.make_date(value)
if not date:
return query
return query.filter(self.column <= self.encode_value(date))
def filter_between(self, query, value):
"""
Filter data with a "between" query. Really this uses ">=" and "<="