Consider collection type for simplified prefilters
This commit is contained in:
parent
85d80fe9fc
commit
d0891d17b9
@ -1420,7 +1420,8 @@ class Collection(BaseCollection):
|
|||||||
return (self.get(href, verify_href=False) for href in self.list())
|
return (self.get(href, verify_href=False) for href in self.list())
|
||||||
|
|
||||||
def get_all_filtered(self, filters):
|
def get_all_filtered(self, filters):
|
||||||
tag, start, end, simple = xmlutils.simplify_prefilters(filters)
|
tag, start, end, simple = xmlutils.simplify_prefilters(
|
||||||
|
filters, collection_tag=self.get_meta("tag"))
|
||||||
if not tag:
|
if not tag:
|
||||||
# no filter
|
# no filter
|
||||||
yield from ((item, simple) for item in self.get_all())
|
yield from ((item, simple) for item in self.get_all())
|
||||||
|
@ -578,7 +578,7 @@ def _param_filter_match(vobject_item, filter_, parent_name, ns):
|
|||||||
return condition
|
return condition
|
||||||
|
|
||||||
|
|
||||||
def simplify_prefilters(filters):
|
def simplify_prefilters(filters, collection_tag="VCALENDAR"):
|
||||||
"""Creates a simplified condition from ``filters``.
|
"""Creates a simplified condition from ``filters``.
|
||||||
|
|
||||||
Returns a tuple (``tag``, ``start``, ``end``, ``simple``) where ``tag`` is
|
Returns a tuple (``tag``, ``start``, ``end``, ``simple``) where ``tag`` is
|
||||||
@ -590,6 +590,9 @@ def simplify_prefilters(filters):
|
|||||||
flat_filters = tuple(chain.from_iterable(filters))
|
flat_filters = tuple(chain.from_iterable(filters))
|
||||||
simple = len(flat_filters) <= 1
|
simple = len(flat_filters) <= 1
|
||||||
for col_filter in flat_filters:
|
for col_filter in flat_filters:
|
||||||
|
if collection_tag != "VCALENDAR":
|
||||||
|
simple = False
|
||||||
|
break
|
||||||
if (col_filter.tag != _tag("C", "comp-filter") or
|
if (col_filter.tag != _tag("C", "comp-filter") or
|
||||||
col_filter.get("name").upper() != "VCALENDAR"):
|
col_filter.get("name").upper() != "VCALENDAR"):
|
||||||
simple = False
|
simple = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user