Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for tiles + support contentlistingtiles without collections #133

Merged
merged 32 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
84781fd
target listingtiles or collections and add layer to tests tiles
djay Jun 18, 2021
ee38cff
flake8
djay Jun 18, 2021
cddc925
Ensure right version of standardtiles
djay Jun 18, 2021
ff3dd34
fix 5.1 versions for 2.4.0 standardtiles
djay Jun 18, 2021
28f534f
move collectionish tile code to .tiles
djay Jun 24, 2021
2e23cc6
target only collections if no mosaic
djay Jun 24, 2021
98074b5
will pick right selector automatically
djay Jun 24, 2021
10222c0
flake8
djay Jun 24, 2021
c5b4e59
handle multiple listing tiles on one page
djay Jun 24, 2021
73030b9
README typos and extra_requires for mosaic with version pins
petschki Jun 25, 2021
8ffdbe2
fix example format
petschki Jun 25, 2021
80f8de7
add warning tiles with no listing, and don't validate tile targets
djay Jun 29, 2021
f5bb4e8
Merge branch 'collectionish' of github.com:collective/collective.coll…
djay Jun 29, 2021
a2ec45f
tile tests use testdoc instead of collection
djay Jun 29, 2021
d8b2c48
don't throw error when adding tile without listing
djay Jun 29, 2021
9186bf9
use plone.api to show_message
djay Jun 29, 2021
b1fc745
test tile shows warning on tile save when no listing
djay Jun 30, 2021
d2ad1ed
use .content_selector to determine if listing is available
djay Jun 30, 2021
eefcb8a
fix bug in test setup for tiles
djay Jun 30, 2021
a67331d
fix select collection when no tile
djay Jun 30, 2021
3358c2c
fix bug in filter portlet
djay Jun 30, 2021
afaeff4
bit more time in test to click alert
djay Jun 30, 2021
a07083a
try to fix alert workaround in test
djay Jun 30, 2021
08ba240
try no alert bug handling
djay Jul 1, 2021
5656d5b
try and ignore invisible alert
djay Jul 1, 2021
411cc92
show bug more clearly
djay Jul 1, 2021
3e1faad
improve tests by checking actual options shown
djay Jul 1, 2021
e1d6b1c
fix bug in tests caused by Type DX field not being inited properly
djay Jul 1, 2021
4bc8ea0
insert tiles in order
djay Jul 1, 2021
27ce5d0
fix for loop robot syntax
djay Jul 1, 2021
7b3da35
fix compile resources running
djay Jul 1, 2021
a20024e
gve warning anytime mosaic page saved and no listing
djay Jul 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 40 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,29 @@ jobs:
- '5.1'
- '5.2'
python-version: ['2.7']
layer:
- Portlet_AjaxDisabled
- Portlet_AjaxEnabled
- Tile
coverage: ['no_coverage']
include:
- plone-version: 5.2
python-version: 3.6
layer: Tile
coverage: coverage
- plone-version: 5.2
python-version: 3.7
layer: Portlet_AjaxDisabled
coverage: coverage
- plone-version: 5.2
python-version: 3.8
layer: Portlet_AjaxEnabled
coverage: coverage
exclude:
- plone-version: 5.0
layer: Tile # standardtiles 2.3.2 does support using the request to query. embed might still be possible
- plone-version: 5.0
layer: Portlet_AjaxEnabled # passes but meaningless as it skips all the tests
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand All @@ -49,10 +65,11 @@ jobs:
~/buildout-cache
~/extends
~/.cache/pip
# key: ${{ runner.os }}-buildout-${{ hashFiles('**/*.cfg') }}-${{ matrix.plone-version }}-${{ matrix.python-version }}
key: ${{ runner.os }}-buildout-${{ matrix.plone-version }}-${{ matrix.python-version }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.plone-version }}-${{ hashFiles('**/*.cfg') }}
restore-keys: |
${{ runner.os }}-buildout-
${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.plone-version }}-
${{ runner.os }}-${{ matrix.python-version }}-
${{ runner.os }}-
- name: setup buildout cache
run: |
mkdir -p ~/buildout-cache/{eggs,downloads}
Expand All @@ -70,43 +87,47 @@ jobs:
bin/pip install zest.pocompile
bin/pocompile src
- name: test
if: ${{ matrix.coverage != 'coverage' }}
run: |
export DISPLAY=:99.0
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
sleep 3
bin/test --all
bin/test --all --layer ${{ matrix.layer }}
- name: createcoverage
if: ${{ matrix.coverage == 'coverage' }}
run: |
export DISPLAY=:99.0
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
sleep 3
bin/createcoverage -t '--all --layer ${{ matrix.layer }}'
bin/coverage json -i
- name: Coveralls
if: ${{ matrix.coverage == 'coverage' }}
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true
flag-name: ${{ matrix.plone-version }}-${{ matrix.python-version }}-${{ matrix.layer }}
- name: code-analysis
if: always()
run: echo "${{ matrix.plone-version }}" | grep 5.1 || bin/code-analysis
- name: Artifact Robot Test Report
if: failure()
uses: actions/upload-artifact@v1
with:
name: test_results
name: test_results-${{ matrix.python-version }}-${{ matrix.plone-version }}-${{ matrix.layer }}
path: ./parts/test
- uses: actions/setup-python@v2
if: failure()
with:
python-version: 2.7
- name: Robottest report
continue-on-error: true
if: failure()
run: |
pip2.7 install popt || pip2.7 install --user popt
grep --include=output.xml -Rl FAIL parts/test | xargs --no-run-if-empty -n 1 popt
- name: createcoverage
run: |
export DISPLAY=:99.0
chromedriver --url-base=/wd/hub &
sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
sleep 3
bin/createcoverage -t '--all'
# bin/createcoverage
bin/coverage json -i
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true
flag-name: ${{ matrix.plone-version }}-${{ matrix.python-version }}

coveralls_finish:
needs: build
Expand Down
41 changes: 28 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ collective.collectionfilter
:target: https://github.com/collective/collective.collectionfilter/actions


Faceted navigation filter for collection results.
Faceted navigation filter for collection or contentlisting tiles.

This Plone 5 addon allows you to filter collections results for additional catalog metadata.
This Plone 5 addon allows you to filter listing results for fields which are indexed in the catalog
(Plones internal search tool).
For example, you can add a subject filter, but also a filter for authors or portal types.
This can also be used to build tag clouds.

The filter types can be extended (see: ``collective.collectionfilter.vocabularies``).

Expand All @@ -35,27 +35,42 @@ There are three portlets/tiles available for filtering:
a list of indexes where the user can sort the filtered result listing


Filter Results with portlets
Filter Results of Collections
----------------------------

Add as many of the filter portlets above to any context you want (most likely the source collection)
and assign a collection with results to it.
Add as many filter/search portlets directly to a collection.

When you select values from the filter the results are loaded asynchronously inside the container
with the selector defined in the field ``Content Selector``. Make sure the selector exists on the
source collection template and on the target page which shows the filtered results.
When you select values from the filter the results are loaded asynchronously onto the page (no page refresh).
Unless you turn off ajax loading in the registery or are using Plone 5.0. If you are using special theme or view template
you can customize ``Content Selector`` and/or ```View Template``` to ensure ajax loading works correctly.
Make sure the selector exists on the source collection template and on the target page which shows the filtered results.

It is also possible to use filter portlets that aren't directly on a collection by specifying a target collection.
To use ajax loading you will need to ensure your content selector is visible on the page. If not using ajax loading selecting a filter
option will redirect you to the collection.


Mosaic Integration
------------------

Use the package extra to install the required dependencies::

[buildout]
...
eggs +=
collective.collectionfilter[mosaic]
...

The three tiles can be added within the Mosaic editor multiple times. Just select them in the ``Insert`` menu
and assign a collection to it. To show the results of the collection simply add a
``Existing Content`` tile which links to the same collection your filter tiles are assigned with.
``Content Listing`` tile.

It's possible to use multiple content listings and multiple filters on the same page by specifying additional unique classes in
the listing tiles settings and then adding these classes to the ``Content Selector`` setting of the filter tile.

If you want to use filter tiles with a collection then add a content listing tile with the setting to use the query from the context.
It is also possible to use the ``Embed content`` tile if there is a unique selector on your collection view.

TODO: right now the collection needs a default_view template, which wraps the result list with a unique selector
inside the ``#content-core`` container. so the collectionfilter can load the filtered result correctly from
the collection into the container inside the existing content tile.


Geolocation filter support
Expand Down
2 changes: 2 additions & 0 deletions base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ collective.collectionfilter =
collective.geolocationbehavior = >=1.6.0
plone.formwidget.geolocation = >=2.2.0
plone.patternslib = >=1.1.0
plone.app.standardtiles = >= 2.4.0
plone.batching = >=1.1.7

# plone.app.standardtiles = 2.3.1 # fix https://github.com/plone/plone.app.standardtiles/issues/111

Expand Down
4 changes: 4 additions & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ eggs =
scripts =
plone-compile-resources
# zopepy


[instance]
eggs+= plone.staticresources
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def read(*rnames):
"plone.app.contenttypes",
],
extras_require={
"mosaic": [
"plone.app.mosaic >= 2.2.3",
"plone.app.standardtiles >= 2.4.0",
],
"geolocation": [
# support for latitude/longitude catalog index
"collective.geolocationbehavior >= 1.6.0",
Expand Down
27 changes: 20 additions & 7 deletions src/collective/collectionfilter/baseviews.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_inner
from collective.collectionfilter import PLONE_VERSION
from collective.collectionfilter.filteritems import get_filter_items
from collective.collectionfilter.filteritems import ICollectionish, get_filter_items
from collective.collectionfilter.interfaces import IGroupByCriteria
from collective.collectionfilter.query import make_query
from collective.collectionfilter.utils import base_query
Expand All @@ -11,7 +11,6 @@
from collective.collectionfilter.vocabularies import TEXT_IDX
from plone import api
from plone.api.portal import get_registry_record as getrec
from plone.app.contenttypes.behaviors.collection import ICollection
from plone.app.uuid.utils import uuidToCatalogBrain
from plone.app.uuid.utils import uuidToObject
from plone.i18n.normalizer.interfaces import IIDNormalizer
Expand Down Expand Up @@ -98,10 +97,22 @@ def pat_options(self):
"collectionUUID": self.collection_uuid,
"reloadURL": self.reload_url,
"ajaxLoad": self.ajax_load,
"contentSelector": self.settings.content_selector,
"contentSelector": self.content_selector,
}
)

@property
def content_selector(self):
if self.settings.content_selector:
return self.settings.content_selector

collectionish = ICollectionish(self.collection.getObject()) if self.collection else None
selector = collectionish.content_selector
if collectionish is None or not selector:
return u"#content-core"
else:
return selector

@property
def ajax_load(self):
if PLONE_VERSION < "5.1":
Expand Down Expand Up @@ -142,6 +153,7 @@ def results(self):
view_name=self.settings.view_name,
cache_enabled=self.settings.cache_enabled,
request_params=self.top_request.form or {},
content_selector=self.settings.content_selector,
)
return results

Expand Down Expand Up @@ -217,7 +229,9 @@ def ajax_url(self):

class BaseSortOnView(BaseView):
def results(self):
collection = self.collection.getObject()
collection = ICollectionish(self.collection.getObject()).selectContent(self.settings.content_selector)
if collection is None:
return
curr_val = self.top_request.get("sort_on", collection.sort_on)
curr_order = self.top_request.get(
"sort_order", "descending" if collection.sort_reversed else "ascending"
Expand Down Expand Up @@ -298,9 +312,8 @@ def locations(self):
# defined by urlquery
custom_query = base_query(request_params)
custom_query = make_query(custom_query)
return ICollection(collection).results(
batch=False, brains=True, custom_query=custom_query
)
return ICollectionish(collection).selectContent(self.settings.content_selector).results(
custom_query, request_params)

@property
def data_geojson(self):
Expand Down
4 changes: 4 additions & 0 deletions src/collective/collectionfilter/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
name="collective.collectionfilter.SortOnIndexes"
/>

<adapter factory=".filteritems.CollectionishCollection"
provides="collective.collectionfilter.interfaces.ICollectionish"
for="plone.app.contenttypes.interfaces.ICollection" />

<subscriber
for="Products.CMFPlone.interfaces.IPloneSiteRoot
zope.traversing.interfaces.IBeforeTraverseEvent"
Expand Down
Loading