Skip to content

Commit 1baa74f

Browse files
authored
Merge pull request #237 from collective/fix-mapfilter-contentselector
Fix getting Collectionish context in geojson call
2 parents 10bb0aa + 1dbdd49 commit 1baa74f

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix selecting Collectionish item in MapsTile/Portlet geojson view. @petschki

src/collective/collectionfilter/baseviews.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,17 @@ def content_selector(self):
106106
return self.settings.content_selector
107107

108108
collectionish = (
109-
ICollectionish(self.collection.getObject()) if self.collection else None
109+
ICollectionish(self.collection.getObject(), None) if self.collection else None
110110
)
111+
111112
if collectionish is not None:
112113
# select default content
113114
collectionish.selectContent()
114-
selector = collectionish.content_selector
115-
if collectionish is None or not selector:
116-
return "#content-core"
117-
else:
118-
return selector
115+
selector = collectionish.content_selector
116+
if selector:
117+
return selector
118+
119+
return "#content-core"
119120

120121
@property
121122
def ajax_load(self):
@@ -413,9 +414,9 @@ def __call__(self):
413414
def locations(self):
414415
custom_query = {} # Additional query to filter the collection
415416

416-
collection = self.context
417+
collection = ICollectionish(self.context, None)
417418
if not collection:
418-
return None
419+
return []
419420

420421
# Recursively transform all to unicode
421422
request_params = safe_decode(get_top_request(self.request).form or {})
@@ -425,7 +426,7 @@ def locations(self):
425426
custom_query = base_query(request_params)
426427
custom_query = make_query(custom_query)
427428

428-
return ICollectionish(collection).results(custom_query, request_params)
429+
return collection.results(custom_query, request_params)
429430

430431

431432
class BaseResetFilterView(BaseFilterView):

src/collective/collectionfilter/tiles/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,11 @@ class CollectionishLayout(CollectionishCollection):
9595
def __init__(self, context):
9696
"""Adapt either collections or contentlisting tile. The name is sorted content selector"""
9797
self.context = context
98+
self.collection = ICollection(self.context, None)
9899

99-
# self.context might not be adaptable
100-
# make sure you select the right content with
101-
# selectContent(selector) after initialization
102-
try:
103-
self.collection = ICollection(self.context)
104-
except TypeError:
105-
self.collection = None
100+
if self.collection is None:
101+
# context might not be adaptable -> try to find a collectionish tile
102+
self.selectContent()
106103

107104
def selectContent(self, selector=None):
108105
"""Pick tile that selector will match, otherwise pick first one.

0 commit comments

Comments
 (0)