diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c367ea7a..1d4adedd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,8 +14,7 @@ jobs: strategy: matrix: config: - - ["Py3.8-Plone5.2", "3.8", "5.2"] - - ["Py3.8-Plone6.0", "3.8", "6.0"] + - ["Py3.8-Plone6.0", "3.8"] runs-on: ubuntu-latest name: ${{ matrix.config[0] }} steps: @@ -42,17 +41,13 @@ jobs: run: | sudo locale-gen en_US.UTF-8 nl_NL@euro python -m venv . - ln -s requirements-${{ matrix.config[2] }}.txt requirements.txt bin/pip install -r requirements.txt - ln -s versions-${{ matrix.config[2] }}.cfg versions.cfg bin/buildout -c .github.cfg - name: Pre commit uses: pre-commit/action@v2.0.0 - if: ${{ matrix.config[2] == '5.2' }} - name: Code Analysis run: | bin/code-analysis - if: ${{ matrix.config[2] == '5.2' }} - name: Test run: | bin/coverage run bin/test -s osha.oira diff --git a/docs/changes.rst b/docs/changes.rst index a9ebaa86..16d88a02 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -1,11 +1,13 @@ Changelog ========= -10.0.6 (unreleased) +10.1.0 (unreleased) ------------------- - Support openpyxl 3.x [reinhardt] +- Remove support and testing infrastructure for Plone 5.2. + [thet] 10.0.5 (2024-12-09) diff --git a/requirements-5.2.txt b/requirements-5.2.txt deleted file mode 100644 index 6001582a..00000000 --- a/requirements-5.2.txt +++ /dev/null @@ -1 +0,0 @@ --r https://raw.githubusercontent.com/euphorie/Euphorie/main/requirements-5.2.txt diff --git a/requirements-6.0.txt b/requirements.txt similarity index 100% rename from requirements-6.0.txt rename to requirements.txt diff --git a/setup.py b/setup.py index 0962bb0e..19407784 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import os -version = "10.0.6.dev0" +version = "10.1.0.dev0" setup( name="osha.oira", @@ -18,7 +18,6 @@ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Plone", - "Framework :: Plone :: 5.2", "Framework :: Plone :: 6.0", "License :: OSI Approved :: GNU General Public License (GPL)", "Programming Language :: Python :: 3", diff --git a/src/osha/oira/client/browser/client.py b/src/osha/oira/client/browser/client.py index 128c0950..5872c631 100644 --- a/src/osha/oira/client/browser/client.py +++ b/src/osha/oira/client/browser/client.py @@ -69,6 +69,14 @@ def validate_ticket(self): if ticket != expected: raise Unauthorized("Invalid ticket") + @property + def page(self): + return int(self.request.get("page", "1")) + + @property + def page_limit(self): + return int(self.request.get("page_limit", "10")) + def __call__(self): """Returns a json meant to be consumed by pat-autosuggest. @@ -178,7 +186,8 @@ def results(self): user = api.user.get_current() if ( - not q or q in all_users["id"] or q in all_users["text"].lower() + self.page == 1 + and (not q or q in all_users["id"] or q in all_users["text"].lower()) ) and api.user.has_permission("Manage portal"): results.append(all_users) @@ -198,7 +207,9 @@ def results(self): else: query["path"] = "/".join((query["path"], q)) - brains = self.filter_permission(catalog(**query), query, user) + b_start = (self.page - 1) * self.page_limit + brains = catalog(**query, b_start=b_start, b_size=self.page_limit) + brains = self.filter_permission(brains, query, user) for brain in brains: results.extend(self._get_mailing_lists_for(brain)) diff --git a/src/osha/oira/client/tests/test_mailing_lists.py b/src/osha/oira/client/tests/test_mailing_lists.py index dcb990c4..c5658cba 100644 --- a/src/osha/oira/client/tests/test_mailing_lists.py +++ b/src/osha/oira/client/tests/test_mailing_lists.py @@ -65,6 +65,64 @@ def test_mailing_lists(self): results, ) + def test_mailing_lists_batching(self): + request = self.request.clone() + request.form = {"user_id": "admin", "page_limit": "2"} + with mock.patch.object( + MailingListsJson, + "addresses_view", + return_value=GroupToAddresses(context=self.portal.client, request=request), + ): + view = MailingListsJson(context=self.portal.client, request=request) + results = view.results + + # Result = 3, because the "general" mailing list is always added + # on page one for admin users. + self.assertEqual(len(results), 3) + self.assertEqual( + results[0], + {"id": "general|QWxsIHVzZXJz", "text": "All users [0 subscribers]"}, + ) + self.assertEqual( + results[1], + { + "id": "nl/test/second-survey|U2Vjb25kIFN1cnZleQ==", + "text": "Second Survey (nl/test/second-survey) [0 subscribers]", + }, + ) + self.assertEqual( + results[2], + { + "id": "nl/ict/software-development|U29mdHdhcmUgZGV2ZWxvcG1lbnQ=", + "text": "Software development (nl/ict/software-development) [0 subscribers]", # noqa: E501 + }, + ) + + request.form = {"user_id": "admin", "page_limit": "2", "page": "2"} + with mock.patch.object( + MailingListsJson, + "addresses_view", + return_value=GroupToAddresses(context=self.portal.client, request=request), + ): + view = MailingListsJson(context=self.portal.client, request=request) + results = view.results + + self.assertEqual(len(results), 2) + self.assertEqual( + results[0], + { + "id": "nl-nl|VGhlIE5ldGhlcmxhbmRzIChubCk=", + "text": "The Netherlands (nl) [0 subscribers]", + }, + ) + self.assertEqual( + results[1], + { + "id": "nl-fr|VGhlIE5ldGhlcmxhbmRzIChmcik=", + "text": "The Netherlands (fr) [0 subscribers]", + }, + ) + def test_group_to_addresses(self): user = Account(loginname="leni@example.nl", password="secret") Session.add(user) diff --git a/versions-5.2.cfg b/versions-5.2.cfg deleted file mode 100644 index dfe438f6..00000000 --- a/versions-5.2.cfg +++ /dev/null @@ -1,45 +0,0 @@ -[buildout] -extends = https://raw.githubusercontent.com/euphorie/Euphorie/main/versions-5.2.cfg - -[versions] -# Use latest Euphorie version for development. -Euphorie = - -# LDAP fixtures -pas.plugins.ldap = 1.8.0 -node.ext.ldap= 1.0b12 - -# LDAP fixtures Known Good Set -bda.cache = 1.3.0 -node = 0.9.26 -node.ext.ugm = 0.9.12 -odict = 1.7.0 -plumber = 1.6 -pyasn1 = 0.4.8 -pyasn1-modules = 0.2.8 -python-ldap = 3.3.1 -python-Levenshtein = 0.12.2 -python-memcached = 1.59 -yafowil = 2.3.3 -yafowil.plone = 4.0.0a3 -yafowil.widget.array = 1.6.1 -yafowil.widget.dict = 1.8 -yafowil.yaml = 1.3.1 - -# automatically picked. -alchemy-mock = 0.4.3 -argparse = 1.4.0 -createcoverage = 1.5 -flake8 = 7.0.0 -mccabe = 0.7.0 -mobile.sniffer = 1.0.0 -passlib = 1.7.4 -plone.formwidget.recaptcha = 2.3.0 -plone.recipe.codeanalysis = 3.0.1 -Products.MemcachedManager = 1.2.1 -pycodestyle = 2.11.1 -pyflakes = 3.2.0 -slc.zopescript = 1.1.4 -zope.app.publication = 4.5 -zope.authentication = 4.5.0 -zope.error = 4.6 diff --git a/versions-6.0.cfg b/versions.cfg similarity index 100% rename from versions-6.0.cfg rename to versions.cfg