diff --git a/.isort.cfg b/.isort.cfg index dbbfee21..40c8f14b 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,3 +1,2 @@ [settings] -profile=black -force_single_line = true +profile=plone diff --git a/CHANGES.rst b/CHANGES.rst index 79c2ba12..26b3f2ad 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,13 +1,54 @@ Changelog ========= -5.4.3 (unreleased) +5.4.8 (unreleased) ------------------ - Add adapters for link integrity for content-types with BlocksField fields. [cekk] +5.4.7 (2024-03-11) +------------------ + +- Add adapter handler for event in rss feed to export + start date instead of publication date + [lucabel] + + +5.4.6 (2024-03-06) +------------------ + +- Added check if value is a dict before using get method. + [eikichi18] + + +5.4.5 (2024-03-05) +------------------ + +- Update plone.restapi requirement to 9.6.0 version + [folix-01] +- Removed monkeypatch for plone.restartpi.serializer.utils.RESOLVEUID_RE + [folix-01] + +5.4.4 (2024-02-20) +------------------ + +- Add adapters for link integrity for content-types with BlocksField fields. + [cekk] +- Fix: occurrences indexing + [mamico] + + +5.4.3 (2024-01-30) +------------------ + +- Upgrade step to remove all custom Googlebot rules from robots.txt + [mamico] + +- Fix: add range_start to function for calculate recurrences in the right way + [eikichi18] + 5.4.2 (2024-01-11) ------------------ diff --git a/docs/conf.py b/docs/conf.py index 0c999488..2deb08ed 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,6 +12,7 @@ import os import sys + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. diff --git a/setup.py b/setup.py index 96656ddd..4f8994ad 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ from setuptools import find_packages from setuptools import setup + long_description = "\n\n".join( [ open("README.rst").read(), @@ -15,7 +16,7 @@ setup( name="redturtle.volto", - version="5.4.3.dev0", + version="5.4.8.dev0", description="Helper package to setup a RedTurtle's Plone site ready to work with Volto.", long_description=long_description, # Get more from https://pypi.org/classifiers/ @@ -58,7 +59,7 @@ "collective.purgebyid", "kitconcept.seo>=2.0.0", "plone.volto>=4.0.0", - "plone.restapi>=8.43.3", + "plone.restapi>=9.6.0", "Products.PortalTransforms>=3.2.0", ], extras_require={ diff --git a/src/redturtle/volto/__init__.py b/src/redturtle/volto/__init__.py index 266d2662..86397e01 100644 --- a/src/redturtle/volto/__init__.py +++ b/src/redturtle/volto/__init__.py @@ -1,17 +1,15 @@ # -*- coding: utf-8 -*- """Init and utils.""" -import logging -import re - from plone.app.content.browser.vocabulary import PERMISSIONS from plone.folder.nogopip import GopipIndex -from plone.restapi.serializer import utils from Products.ZCatalog.Catalog import Catalog +from redturtle.volto.catalogplan import Catalog_sorted_search_indexes from zope.i18nmessageid import MessageFactory from ZTUtils.Lazy import LazyCat from ZTUtils.Lazy import LazyMap -from redturtle.volto.catalogplan import Catalog_sorted_search_indexes +import logging + logger = logging.getLogger(__name__) @@ -77,6 +75,3 @@ def Catalog_sortResults( logger.info("install monkey patch for Products.ZCatalog.Catalog.Catalog.sortResults") Catalog._orig_sortResults = Catalog.sortResults Catalog.sortResults = Catalog_sortResults - -# patch plone.restapi regexp to catch also other -utils.RESOLVEUID_RE = re.compile("^(?:|.*/)resolve[Uu]id/([^/]*)/?(.*)$") diff --git a/src/redturtle/volto/adapters/blocks_linkintegrity.py b/src/redturtle/volto/adapters/blocks_linkintegrity.py index 7b81a954..e0a06ad2 100644 --- a/src/redturtle/volto/adapters/blocks_linkintegrity.py +++ b/src/redturtle/volto/adapters/blocks_linkintegrity.py @@ -7,16 +7,17 @@ from plone.dexterity.interfaces import IDexterityFTI from plone.dexterity.interfaces import IDexterityItem from plone.dexterity.utils import getAdditionalSchemata -from plone.restapi.blocks import iter_block_transform_handlers, visit_blocks +from plone.restapi.blocks import iter_block_transform_handlers +from plone.restapi.blocks import visit_blocks from plone.restapi.blocks_linkintegrity import BlocksRetriever as BaseBlocksRetriever from plone.restapi.blocks_linkintegrity import ( - TextBlockLinksRetriever as BaseTextBlockLinksRetriever, + GenericBlockLinksRetriever as BaseGenericBlockLinksRetriever, ) from plone.restapi.blocks_linkintegrity import ( SlateBlockLinksRetriever as BaseSlateBlockLinksRetriever, ) from plone.restapi.blocks_linkintegrity import ( - GenericBlockLinksRetriever as BaseGenericBlockLinksRetriever, + TextBlockLinksRetriever as BaseTextBlockLinksRetriever, ) from plone.restapi.interfaces import IBlockFieldLinkIntegrityRetriever from redturtle.volto.interfaces import IRedturtleVoltoLayer @@ -54,6 +55,8 @@ def retrieveLinks(self): links |= set(extractLinks(value.raw)) elif isinstance(field, BlocksField): value = field.get(self.context) + if not isinstance(value, dict): + continue blocks = value.get("blocks", {}) if not blocks: continue diff --git a/src/redturtle/volto/adapters/configure.zcml b/src/redturtle/volto/adapters/configure.zcml index 9d54aa3d..ec239441 100644 --- a/src/redturtle/volto/adapters/configure.zcml +++ b/src/redturtle/volto/adapters/configure.zcml @@ -37,4 +37,22 @@ provides="plone.restapi.interfaces.IBlockFieldLinkIntegrityRetriever" /> + + + + + + diff --git a/src/redturtle/volto/adapters/rss.py b/src/redturtle/volto/adapters/rss.py new file mode 100644 index 00000000..6517f0b4 --- /dev/null +++ b/src/redturtle/volto/adapters/rss.py @@ -0,0 +1,24 @@ +from DateTime import DateTime +from plone.app.contenttypes.interfaces import IEvent + + +try: + from plone.base.interfaces.syndication import IFeed +except ModuleNotFoundError: + from Products.CMFPlone.interfaces.syndication import IFeed + +from Products.CMFPlone.browser.syndication.adapters import DexterityItem +from zope.component import adapter + + +@adapter(IEvent, IFeed) +class EventItem(DexterityItem): + @property + def startdate(self): + """ + Same format as other dates in + Products.CMFPlone.browser.syndication.adapters + """ + date = self.context.start.isoformat() + if date: + return DateTime(date) diff --git a/src/redturtle/volto/adapters/stringinterp.py b/src/redturtle/volto/adapters/stringinterp.py index b97a007e..a4a4e215 100644 --- a/src/redturtle/volto/adapters/stringinterp.py +++ b/src/redturtle/volto/adapters/stringinterp.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from plone.stringinterp.adapters import BaseSubstitution from Products.CMFCore.interfaces import IContentish +from redturtle.volto import _ from zope.component import adapter -from redturtle.volto import _ try: from plone.stringinterp import _ as stringinterp_mf diff --git a/src/redturtle/volto/browser/controlpanel.py b/src/redturtle/volto/browser/controlpanel.py index 46d6c97c..e157567e 100644 --- a/src/redturtle/volto/browser/controlpanel.py +++ b/src/redturtle/volto/browser/controlpanel.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper from plone.app.registry.browser.controlpanel import RegistryEditForm - from redturtle.volto import _ from redturtle.volto.interfaces import IRedTurtleVoltoSettings diff --git a/src/redturtle/volto/browser/find_blocks.py b/src/redturtle/volto/browser/find_blocks.py index 3627348a..dec9a452 100644 --- a/src/redturtle/volto/browser/find_blocks.py +++ b/src/redturtle/volto/browser/find_blocks.py @@ -1,14 +1,15 @@ # -*- coding: utf-8 -*- -import json -import logging -from copy import deepcopy - from Acquisition import aq_base +from copy import deepcopy from plone import api from plone.dexterity.utils import iterSchemata from Products.Five import BrowserView from zope.schema import getFieldsInOrder +import json +import logging + + logger = logging.getLogger(__name__) BLOCKS = [ diff --git a/src/redturtle/volto/browser/fix_links.py b/src/redturtle/volto/browser/fix_links.py index 9777a10e..686a18bd 100644 --- a/src/redturtle/volto/browser/fix_links.py +++ b/src/redturtle/volto/browser/fix_links.py @@ -1,18 +1,19 @@ # -*- coding: utf-8 -*- -import json -import logging -import re -from urllib.parse import urlparse -from urllib.parse import urlunparse - from Acquisition import aq_base from plone import api from plone.dexterity.utils import iterSchemata from plone.restapi.interfaces import IFieldDeserializer from Products.Five import BrowserView +from urllib.parse import urlparse +from urllib.parse import urlunparse from zope.component import queryMultiAdapter from zope.schema import getFieldsInOrder +import json +import logging +import re + + logger = logging.getLogger(__name__) diff --git a/src/redturtle/volto/browser/overrides/Products.CMFPlone.browser.syndication.templates.RSS.pt b/src/redturtle/volto/browser/overrides/Products.CMFPlone.browser.syndication.templates.RSS.pt index b62afb5d..eb2bbdd3 100644 --- a/src/redturtle/volto/browser/overrides/Products.CMFPlone.browser.syndication.templates.RSS.pt +++ b/src/redturtle/volto/browser/overrides/Products.CMFPlone.browser.syndication.templates.RSS.pt @@ -56,7 +56,7 @@ Item - Published or last modified date if no published date + Published or last modified date if no published date Type diff --git a/src/redturtle/volto/browser/sitemap.py b/src/redturtle/volto/browser/sitemap.py index c451acbb..6b26edd1 100644 --- a/src/redturtle/volto/browser/sitemap.py +++ b/src/redturtle/volto/browser/sitemap.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -import datetime - from BTrees.OOBTree import OOBTree from plone.app.layout.sitemap.sitemap import SiteMapView as LayoutSiteMapView from plone.registry.interfaces import IRegistry @@ -8,6 +6,8 @@ from Products.CMFPlone.interfaces import IPloneSiteRoot from zope.component import getUtility +import datetime + class SiteMapView(LayoutSiteMapView): def objects(self): diff --git a/src/redturtle/volto/config/__init__.py b/src/redturtle/volto/config/__init__.py index 34c0cdb6..caf3ecbe 100644 --- a/src/redturtle/volto/config/__init__.py +++ b/src/redturtle/volto/config/__init__.py @@ -1,3 +1,4 @@ import os + MAX_LIMIT = int(os.environ.get("REDTURTLE_VOLTO_MAX_LIMIT_SEARCH") or 500) diff --git a/src/redturtle/volto/interfaces.py b/src/redturtle/volto/interfaces.py index 67d27c2c..e495492a 100644 --- a/src/redturtle/volto/interfaces.py +++ b/src/redturtle/volto/interfaces.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- from plone.restapi.controlpanels.interfaces import IControlpanel +from redturtle.volto import _ from zope.interface import Interface from zope.publisher.interfaces.browser import IDefaultBrowserLayer from zope.schema import Bool -from redturtle.volto import _ - class IRedturtleVoltoLayer(IDefaultBrowserLayer): """Marker interface that defines a browser layer.""" diff --git a/src/redturtle/volto/locales/update.py b/src/redturtle/volto/locales/update.py index 37421d50..a694c489 100644 --- a/src/redturtle/volto/locales/update.py +++ b/src/redturtle/volto/locales/update.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- import os +import pkg_resources import subprocess -import pkg_resources domain = "redturtle.volto" os.chdir(pkg_resources.resource_filename(domain, "")) diff --git a/src/redturtle/volto/monkey.py b/src/redturtle/volto/monkey.py index 7dfd4c70..609aa18b 100644 --- a/src/redturtle/volto/monkey.py +++ b/src/redturtle/volto/monkey.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -import datetime -import os - from Acquisition import aq_base from plone.app.caching import purge from plone.app.event.base import dt_start_of_day @@ -11,10 +8,14 @@ from plone.event.interfaces import IEventAccessor from plone.event.interfaces import IRecurrenceSupport from plone.event.recurrence import recurrence_sequence_ical -from plone.event.utils import pydt + +# from plone.event.utils import pydt from Products.CMFPlone.interfaces import IConstrainTypes from zope.globalrequest import getRequest +import datetime +import os + def occurrences(self, range_start=None, range_end=None): """Return all occurrences of an event, possibly within a start and end @@ -75,13 +76,20 @@ def occurrences(self, range_start=None, range_end=None): # but doing it for backwards compatibility as views/templates # still rely on acquisition-wrapped objects. def get_obj(start): - if pydt(event_start.replace(microsecond=0)) == start: - # If the occurrence date is the same as the event object, the - # occurrence is the event itself. return it as such. - # Dates from recurrence_sequence_ical are explicitly without - # microseconds, while event.start may contain it. So we have to - # remove it for a valid comparison. - return self.context + # THIS IS THE PATCH + # + # -- questa parte รจ stata commentata, altrtimenti se lo start date coincide con la data di inizio dell'evento + # -- la funzione ritorna l'evento stesso, invece che la sua occorrenza e l'indice end non contiene + # -- tutte le date di end, ma solo quella dell'evento stesso + # + # if pydt(event_start.replace(microsecond=0)) == start: + # # If the occurrence date is the same as the event object, the + # # occurrence is the event itself. return it as such. + # # Dates from recurrence_sequence_ical are explicitly without + # # microseconds, while event.start may contain it. So we have to + # # remove it for a valid comparison. + # return self.context + # END OF PATCH return Occurrence( id=str(start.date()), start=start, end=start + duration ).__of__(self.context) @@ -93,7 +101,7 @@ def get_obj(start): def _recurrence_upcoming_event(self): """Return the next upcoming event""" adapter = IRecurrenceSupport(self.context) - occs = adapter.occurrences() + occs = adapter.occurrences(range_start=self.context.start) try: return next(occs) except StopIteration: diff --git a/src/redturtle/volto/profiles/default/metadata.xml b/src/redturtle/volto/profiles/default/metadata.xml index ac6727fb..f40d93d8 100644 --- a/src/redturtle/volto/profiles/default/metadata.xml +++ b/src/redturtle/volto/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 4301 + 4303 profile-plone.volto:default profile-plone.app.caching:with-caching-proxy diff --git a/src/redturtle/volto/restapi/deserializer/blocks.py b/src/redturtle/volto/restapi/deserializer/blocks.py index 868c2f4b..ed19fefa 100644 --- a/src/redturtle/volto/restapi/deserializer/blocks.py +++ b/src/redturtle/volto/restapi/deserializer/blocks.py @@ -1,14 +1,13 @@ # -*- coding: utf-8 -*- from copy import deepcopy - from plone.restapi.behaviors import IBlocks from plone.restapi.deserializer.blocks import path2uid from plone.restapi.interfaces import IBlockFieldDeserializationTransformer from Products.CMFPlone.interfaces import IPloneSiteRoot +from redturtle.volto.interfaces import IRedturtleVoltoLayer from zope.component import adapter from zope.interface import implementer -from redturtle.volto.interfaces import IRedturtleVoltoLayer EXCLUDE_KEYS = ["@type", "token", "value", "@id", "query"] EXCLUDE_TYPES = ["title", "listing", "calendar", "searchEvents"] diff --git a/src/redturtle/volto/restapi/deserializer/dxfields.py b/src/redturtle/volto/restapi/deserializer/dxfields.py index 3750c740..9a530198 100644 --- a/src/redturtle/volto/restapi/deserializer/dxfields.py +++ b/src/redturtle/volto/restapi/deserializer/dxfields.py @@ -1,7 +1,4 @@ # -*- coding: utf-8 -*- -import dateutil -import lxml -import pytz from plone.app.contenttypes.interfaces import ILink from plone.app.dexterity.behaviors.metadata import IPublication from plone.app.event.base import default_timezone @@ -21,6 +18,7 @@ from Products.CMFPlone.utils import safe_unicode from pytz import timezone from pytz import utc +from redturtle.volto.interfaces import IRedturtleVoltoLayer from z3c.form.interfaces import IDataManager from zope.component import adapter from zope.component import getMultiAdapter @@ -29,7 +27,9 @@ from zope.schema.interfaces import IDatetime from zope.schema.interfaces import ITextLine -from redturtle.volto.interfaces import IRedturtleVoltoLayer +import dateutil +import lxml +import pytz @implementer(IFieldDeserializer) diff --git a/src/redturtle/volto/restapi/deserializer/relationfield.py b/src/redturtle/volto/restapi/deserializer/relationfield.py index 0693e119..122cc5ea 100644 --- a/src/redturtle/volto/restapi/deserializer/relationfield.py +++ b/src/redturtle/volto/restapi/deserializer/relationfield.py @@ -1,9 +1,9 @@ -from urllib.parse import urlparse - from plone.dexterity.interfaces import IDexterityContent from plone.restapi.deserializer.dxfields import DefaultFieldDeserializer from plone.restapi.interfaces import IFieldDeserializer from Products.CMFCore.utils import getToolByName +from redturtle.volto.interfaces import IRedturtleVoltoLayer +from urllib.parse import urlparse from z3c.relationfield.interfaces import IRelationChoice from zope.component import adapter from zope.component import getMultiAdapter @@ -11,8 +11,6 @@ from zope.interface import implementer from zope.intid.interfaces import IIntIds -from redturtle.volto.interfaces import IRedturtleVoltoLayer - @implementer(IFieldDeserializer) @adapter(IRelationChoice, IDexterityContent, IRedturtleVoltoLayer) diff --git a/src/redturtle/volto/restapi/search/query.py b/src/redturtle/volto/restapi/search/query.py index e5646a0e..0f6da732 100644 --- a/src/redturtle/volto/restapi/search/query.py +++ b/src/redturtle/volto/restapi/search/query.py @@ -1,16 +1,15 @@ # -*- coding: utf-8 -*- -import re - from plone.restapi.interfaces import IIndexQueryParser from plone.restapi.search.query import ( ZCTextIndexQueryParser as BaseZCTextIndexQueryParser, ) from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex +from redturtle.volto.interfaces import IRedturtleVoltoLayer from zope.component import adapter -from zope.interface import Interface from zope.interface import implementer +from zope.interface import Interface -from redturtle.volto.interfaces import IRedturtleVoltoLayer +import re @implementer(IIndexQueryParser) diff --git a/src/redturtle/volto/restapi/serializer/blocks.py b/src/redturtle/volto/restapi/serializer/blocks.py index ce0b3bc9..f32fb0a5 100644 --- a/src/redturtle/volto/restapi/serializer/blocks.py +++ b/src/redturtle/volto/restapi/serializer/blocks.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- from copy import deepcopy - from plone import api from plone.restapi.behaviors import IBlocks from plone.restapi.interfaces import IBlockFieldSerializationTransformer from plone.restapi.interfaces import ISerializeToJsonSummary from plone.restapi.serializer.blocks import uid_to_url from Products.CMFPlone.interfaces import IPloneSiteRoot +from redturtle.volto.interfaces import IRedturtleVoltoLayer from zope.component import adapter from zope.component import getMultiAdapter from zope.globalrequest import getRequest from zope.interface import implementer -from redturtle.volto.interfaces import IRedturtleVoltoLayer EXCLUDE_KEYS = ["@type"] EXCLUDE_TYPES = ["title", "listing"] diff --git a/src/redturtle/volto/restapi/serializer/dxfields.py b/src/redturtle/volto/restapi/serializer/dxfields.py index 1565e8a3..d5f81fe2 100644 --- a/src/redturtle/volto/restapi/serializer/dxfields.py +++ b/src/redturtle/volto/restapi/serializer/dxfields.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -import re - from plone.app.contenttypes.interfaces import ILink from plone.app.contenttypes.utils import replace_link_variables_by_paths from plone.app.dexterity.behaviors.metadata import IPublication @@ -9,12 +7,14 @@ from plone.restapi.serializer.converters import json_compatible from plone.restapi.serializer.dxfields import DefaultFieldSerializer from plone.restapi.serializer.utils import uid_to_url +from redturtle.volto.interfaces import IRedturtleVoltoLayer from zope.component import adapter from zope.interface import implementer from zope.schema.interfaces import IDatetime from zope.schema.interfaces import ITextLine -from redturtle.volto.interfaces import IRedturtleVoltoLayer +import re + RESOLVEUID_RE = re.compile(".*?/resolve[Uu]id/([^/]*)/?(.*)$") diff --git a/src/redturtle/volto/restapi/serializer/summary.py b/src/redturtle/volto/restapi/serializer/summary.py index 901fcdb3..83e70c1c 100644 --- a/src/redturtle/volto/restapi/serializer/summary.py +++ b/src/redturtle/volto/restapi/serializer/summary.py @@ -8,11 +8,11 @@ DefaultJSONSummarySerializer as BaseSerializer, ) from plone.restapi.serializer.utils import uid_to_url +from redturtle.volto.interfaces import IRedturtleVoltoLayer from zope.component import adapter -from zope.interface import Interface from zope.interface import implementer +from zope.interface import Interface -from redturtle.volto.interfaces import IRedturtleVoltoLayer EMPTY_STRINGS = ["None"] diff --git a/src/redturtle/volto/restapi/services/controlpanel.py b/src/redturtle/volto/restapi/services/controlpanel.py index 47915d6b..3606ef6e 100644 --- a/src/redturtle/volto/restapi/services/controlpanel.py +++ b/src/redturtle/volto/restapi/services/controlpanel.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- from plone.restapi.controlpanels import RegistryConfigletPanel -from zope.component import adapter -from zope.interface import Interface -from zope.interface import implementer - from redturtle.volto.interfaces import IRedTurtleVoltoSettings from redturtle.volto.interfaces import IRedTurtleVoltoSettingsControlpanel +from zope.component import adapter +from zope.interface import implementer +from zope.interface import Interface @adapter(Interface, Interface) diff --git a/src/redturtle/volto/restapi/services/navigation/get.py b/src/redturtle/volto/restapi/services/navigation/get.py index 26c85005..4490a013 100644 --- a/src/redturtle/volto/restapi/services/navigation/get.py +++ b/src/redturtle/volto/restapi/services/navigation/get.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from plone.app.layout.navigation.navtree import NavtreeStrategyBase from plone.app.layout.navigation.navtree import buildFolderTree +from plone.app.layout.navigation.navtree import NavtreeStrategyBase from plone.dexterity.interfaces import IDexterityContainer from plone.restapi.interfaces import IExpandableElement from plone.restapi.services import Service from zope.component import adapter -from zope.interface import Interface from zope.interface import implementer +from zope.interface import Interface @implementer(IExpandableElement) diff --git a/src/redturtle/volto/restapi/services/querystringsearch/get.py b/src/redturtle/volto/restapi/services/querystringsearch/get.py index 72cdaf60..fa1948cc 100644 --- a/src/redturtle/volto/restapi/services/querystringsearch/get.py +++ b/src/redturtle/volto/restapi/services/querystringsearch/get.py @@ -1,8 +1,5 @@ # -*- coding: utf-8 -*- -import logging from datetime import datetime -from urllib import parse - from DateTime import DateTime from plone import api from plone.app.event.base import get_events @@ -14,14 +11,17 @@ from plone.restapi.interfaces import ISerializeToJson from plone.restapi.interfaces import ISerializeToJsonSummary from plone.restapi.services import Service -from plone.restapi.services.querystringsearch.get import SUPPORT_NOT_UUID_QUERIES from plone.restapi.services.querystringsearch.get import ( QuerystringSearch as BaseQuerystringSearch, ) +from plone.restapi.services.querystringsearch.get import SUPPORT_NOT_UUID_QUERIES +from redturtle.volto.config import MAX_LIMIT +from urllib import parse from zExceptions import BadRequest from zope.component import getMultiAdapter -from redturtle.volto.config import MAX_LIMIT +import logging + logger = logging.getLogger(__name__) diff --git a/src/redturtle/volto/restapi/services/search/get.py b/src/redturtle/volto/restapi/services/search/get.py index 302fe42c..783c210d 100644 --- a/src/redturtle/volto/restapi/services/search/get.py +++ b/src/redturtle/volto/restapi/services/search/get.py @@ -4,11 +4,11 @@ from plone.restapi.search.handler import SearchHandler as OriginalHandler from plone.restapi.search.utils import unflatten_dotted_dict from plone.restapi.services import Service -from zope.component import getMultiAdapter - from redturtle.volto import logger from redturtle.volto.config import MAX_LIMIT from redturtle.volto.interfaces import IRedTurtleVoltoSettings +from zope.component import getMultiAdapter + # search for 'ranking' in 'SearchableText' and rank very high # when the term is in 'Subject' and high when it is in 'Title'. diff --git a/src/redturtle/volto/setuphandlers.py b/src/redturtle/volto/setuphandlers.py index 3eff52a6..95ea06dc 100644 --- a/src/redturtle/volto/setuphandlers.py +++ b/src/redturtle/volto/setuphandlers.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- -import logging - from plone import api from Products.CMFPlone.interfaces import INonInstallable from zope.interface import implementer +import logging + + logger = logging.getLogger(__name__) @@ -15,6 +16,7 @@ def getNonInstallableProfiles(self): return ["redturtle.volto:uninstall"] +# DEPRECATED def upgrade_robots_txt(context): robots = api.portal.get_registry_record("plone.robots_txt") lines = robots.splitlines() @@ -62,9 +64,26 @@ def upgrade_robots_txt(context): ) +def remove_custom_googlebot(context): + robots = api.portal.get_registry_record("plone.robots_txt") + googlebot_user_agent = "User-Agent: Googlebot".lower().replace(" ", "") + lines = [] + googlebot = False + for line in robots.splitlines(): + if line.lower().replace(" ", "") == googlebot_user_agent: + googlebot = True + elif line.startswith("User-Agent:"): + googlebot = False + if not googlebot: + lines.append(line) + lines = "\n".join(lines) + api.portal.set_registry_record("plone.robots_txt", lines) + logger.info("Upgrade robots.txt removing custom googlebot") + + def post_install(context): """Post install script""" - upgrade_robots_txt(context) + remove_custom_googlebot(context) def uninstall(context): diff --git a/src/redturtle/volto/testing.py b/src/redturtle/volto/testing.py index 3422c56e..81d9eb91 100644 --- a/src/redturtle/volto/testing.py +++ b/src/redturtle/volto/testing.py @@ -1,18 +1,18 @@ # -*- coding: utf-8 -*- -import collective.volto.cookieconsent -import kitconcept.seo -import plone.app.caching -import plone.restapi -import plone.volto from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE +from plone.app.testing import applyProfile from plone.app.testing import FunctionalTesting from plone.app.testing import IntegrationTesting from plone.app.testing import PloneSandboxLayer -from plone.app.testing import applyProfile from plone.restapi.testing import PloneRestApiDXLayer from plone.testing import z2 +import collective.volto.cookieconsent +import kitconcept.seo +import plone.app.caching +import plone.restapi +import plone.volto import redturtle.volto diff --git a/src/redturtle/volto/tests/test_advancedsearch.py b/src/redturtle/volto/tests/test_advancedsearch.py index aad4f475..abf58c55 100644 --- a/src/redturtle/volto/tests/test_advancedsearch.py +++ b/src/redturtle/volto/tests/test_advancedsearch.py @@ -1,17 +1,16 @@ # -*- coding: utf-8 -*- -import unittest - from DateTime import DateTime from plone import api +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles from plone.restapi.testing import RelativeSession -from transaction import commit - from redturtle.volto.interfaces import IRedTurtleVoltoSettings from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +from transaction import commit + +import unittest class BaseTest(unittest.TestCase): diff --git a/src/redturtle/volto/tests/test_blocks_searchable_text.py b/src/redturtle/volto/tests/test_blocks_searchable_text.py index 5033231d..cc70a6a8 100644 --- a/src/redturtle/volto/tests/test_blocks_searchable_text.py +++ b/src/redturtle/volto/tests/test_blocks_searchable_text.py @@ -1,12 +1,11 @@ # -*- coding: utf-8 -*- -import unittest - from plone import api -from plone.app.testing import TEST_USER_ID from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from redturtle.volto.testing import REDTURTLE_VOLTO_FUNCTIONAL_TESTING from transaction import commit -from redturtle.volto.testing import REDTURTLE_VOLTO_FUNCTIONAL_TESTING +import unittest class TestBlocksSearchable(unittest.TestCase): diff --git a/src/redturtle/volto/tests/test_blocks_serializer.py b/src/redturtle/volto/tests/test_blocks_serializer.py index 0a890c22..4833967e 100644 --- a/src/redturtle/volto/tests/test_blocks_serializer.py +++ b/src/redturtle/volto/tests/test_blocks_serializer.py @@ -1,20 +1,16 @@ # -*- coding: utf-8 -*- -import os -import unittest - from plone import api +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles -from plone.registry.interfaces import IRegistry from plone.restapi.interfaces import ISerializeToJsonSummary from plone.restapi.testing import RelativeSession +from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING from transaction import commit from zope.component import getMultiAdapter -from zope.component import getUtility -from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import unittest class TestBlocksSerializer(unittest.TestCase): @@ -22,15 +18,6 @@ class TestBlocksSerializer(unittest.TestCase): maxDiff = None def setUp(self): - tz = os.environ.get("TZ", "UTC") - registry = getUtility(IRegistry) - self._orig_tz = ( - registry["plone.portal_timezone"], - registry["plone.available_timezones"], - ) - registry["plone.portal_timezone"] = tz - registry["plone.available_timezones"] = [tz] - self.app = self.layer["app"] self.portal = self.layer["portal"] self.request = self.layer["request"] @@ -57,9 +44,6 @@ def setUp(self): def tearDown(self): self.api_session.close() - registry = getUtility(IRegistry) - registry["plone.portal_timezone"] = self._orig_tz[0] - registry["plone.available_timezones"] = self._orig_tz[1] def test_blocks_internal_refs_with_uid_get_serialized_as_summary(self): self.page_a.blocks = { diff --git a/src/redturtle/volto/tests/test_catalog_limit_patches.py b/src/redturtle/volto/tests/test_catalog_limit_patches.py index 1127c5ac..1ba26966 100644 --- a/src/redturtle/volto/tests/test_catalog_limit_patches.py +++ b/src/redturtle/volto/tests/test_catalog_limit_patches.py @@ -1,17 +1,16 @@ # -*- coding: utf-8 -*- -import json -import unittest -from urllib.parse import quote - from plone import api +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles from plone.restapi.testing import RelativeSession +from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING from transaction import commit +from urllib.parse import quote -from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import json +import unittest class CatalogLimitPatches(unittest.TestCase): diff --git a/src/redturtle/volto/tests/test_content_types.py b/src/redturtle/volto/tests/test_content_types.py index 470195c8..9d1f7ed1 100644 --- a/src/redturtle/volto/tests/test_content_types.py +++ b/src/redturtle/volto/tests/test_content_types.py @@ -1,17 +1,16 @@ # -*- coding: utf-8 -*- """Setup tests for this package.""" -import unittest - from plone import api +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles from plone.restapi.testing import RelativeSession - from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING from redturtle.volto.testing import REDTURTLE_VOLTO_INTEGRATION_TESTING +import unittest + class TestContentTypes(unittest.TestCase): layer = REDTURTLE_VOLTO_INTEGRATION_TESTING diff --git a/src/redturtle/volto/tests/test_controlpanel_api.py b/src/redturtle/volto/tests/test_controlpanel_api.py index 2c2fcf2a..c2eb3704 100644 --- a/src/redturtle/volto/tests/test_controlpanel_api.py +++ b/src/redturtle/volto/tests/test_controlpanel_api.py @@ -1,14 +1,13 @@ # -*- coding: utf-8 -*- -import unittest - +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles from plone.restapi.testing import RelativeSession - from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import unittest + class ControlpanelTest(unittest.TestCase): layer = REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING diff --git a/src/redturtle/volto/tests/test_ct_link.py b/src/redturtle/volto/tests/test_ct_link.py index a199e4c5..5fb981c1 100644 --- a/src/redturtle/volto/tests/test_ct_link.py +++ b/src/redturtle/volto/tests/test_ct_link.py @@ -1,16 +1,15 @@ # -*- coding: utf-8 -*- """Setup tests for this package.""" -import unittest - from plone import api +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles from plone.restapi.testing import RelativeSession +from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING from transaction import commit -from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import unittest class TestContentTypeLink(unittest.TestCase): diff --git a/src/redturtle/volto/tests/test_dxfield_deserializer.py b/src/redturtle/volto/tests/test_dxfield_deserializer.py index 3ada70b8..03561a09 100644 --- a/src/redturtle/volto/tests/test_dxfield_deserializer.py +++ b/src/redturtle/volto/tests/test_dxfield_deserializer.py @@ -1,16 +1,15 @@ -import unittest - -import transaction -from plone.app.testing import TEST_USER_ID -from plone.app.testing import TEST_USER_NAME from plone.app.testing import login from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from plone.app.testing import TEST_USER_NAME from plone.dexterity.utils import iterSchemata from plone.restapi.interfaces import IFieldDeserializer from Products.CMFCore.utils import getToolByName +from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING from zope.component import getMultiAdapter -from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import transaction +import unittest class TestDXFieldDeserializer(unittest.TestCase): diff --git a/src/redturtle/volto/tests/test_monkeypatches.py b/src/redturtle/volto/tests/test_monkeypatches.py index 4cf0264c..a10ade03 100644 --- a/src/redturtle/volto/tests/test_monkeypatches.py +++ b/src/redturtle/volto/tests/test_monkeypatches.py @@ -1,13 +1,12 @@ # -*- coding: utf-8 -*- -import unittest - from plone import api -from plone.app.testing import TEST_USER_ID from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID from Products.CMFPlone.interfaces import ISelectableConstrainTypes - from redturtle.volto.testing import REDTURTLE_VOLTO_FUNCTIONAL_TESTING +import unittest + class TestRespectLocallyAllowedTypes(unittest.TestCase): layer = REDTURTLE_VOLTO_FUNCTIONAL_TESTING diff --git a/src/redturtle/volto/tests/test_publication_fields_fixes.py b/src/redturtle/volto/tests/test_publication_fields_fixes.py index 40390024..d2c4fce5 100644 --- a/src/redturtle/volto/tests/test_publication_fields_fixes.py +++ b/src/redturtle/volto/tests/test_publication_fields_fixes.py @@ -1,33 +1,22 @@ # -*- coding: utf-8 -*- -import os -import unittest - -from DateTime import DateTime +from datetime import timedelta +from plone.app.event.base import localized_now +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles -from plone.registry.interfaces import IRegistry +from plone.restapi.serializer.converters import json_compatible from plone.restapi.testing import RelativeSession +from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING from transaction import commit -from zope.component import getUtility -from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import unittest class TestPublicationFieldsFixes(unittest.TestCase): layer = REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING def setUp(self): - tz = os.environ.get("TZ", "UTC") - - registry = getUtility(IRegistry) - self._orig_tz = ( - registry["plone.portal_timezone"], - registry["plone.available_timezones"], - ) - registry["plone.portal_timezone"] = tz - registry["plone.available_timezones"] = [tz] self.app = self.layer["app"] self.portal = self.layer["portal"] self.portal_url = self.portal.absolute_url() @@ -37,25 +26,20 @@ def setUp(self): self.api_session.headers.update({"Accept": "application/json"}) self.api_session.auth = (SITE_OWNER_NAME, SITE_OWNER_PASSWORD) - commit() - def tearDown(self): self.api_session.close() - registry = getUtility(IRegistry) - registry["plone.portal_timezone"] = self._orig_tz[0] - registry["plone.available_timezones"] = self._orig_tz[1] def test_set_effective_date_store_right_value_in_plone(self): - effective = DateTime() - expires = effective + 1 + effective = localized_now() + expires = effective + timedelta(days=1) self.api_session.post( self.portal_url, json={ "@type": "Document", "id": "mydocument", "title": "My Document", - "effective": "{}Z".format(effective.utcdatetime().isoformat()), - "expires": "{}Z".format(expires.utcdatetime().isoformat()), + "effective": f"{json_compatible(effective)}", + "expires": f"{json_compatible(expires)}", }, ) commit() diff --git a/src/redturtle/volto/tests/test_recurrence.py b/src/redturtle/volto/tests/test_recurrence.py new file mode 100644 index 00000000..190982fb --- /dev/null +++ b/src/redturtle/volto/tests/test_recurrence.py @@ -0,0 +1,46 @@ +from datetime import datetime +from datetime import timedelta +from plone.app.event.testing import set_browserlayer +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from plone.dexterity.utils import createContentInContainer +from redturtle.volto.testing import REDTURTLE_VOLTO_FUNCTIONAL_TESTING + +import unittest + + +class TestOccurrences(unittest.TestCase): + layer = REDTURTLE_VOLTO_FUNCTIONAL_TESTING + + def setUp(self): + self.portal = self.layer["portal"] + self.request = self.layer["request"] + set_browserlayer(self.request) + setRoles(self.portal, TEST_USER_ID, ["Manager"]) + self.start_date = datetime.strptime("01/01/2024 10:00:00", "%d/%m/%Y %H:%M:%S") + self.end_date = self.start_date + timedelta(hours=1) + + self.event = createContentInContainer( + self.portal, + "Event", + id="test-event", + title="Test Event", + start=self.start_date, + end=self.end_date, + location="Vienna", + recurrence="RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO;COUNT=50", + ) + + def test_get_occurrences_from_catalog(self): + catalog = self.portal.portal_catalog + + start_date_search = datetime.strptime( + "02/01/2024 10:00:00", "%d/%m/%Y %H:%M:%S" + ) + end_date_search = start_date_search + timedelta(hours=1) + + results = catalog( + end={"query": (start_date_search, end_date_search), "range": "min:max"} + ) + + self.assertFalse(results) diff --git a/src/redturtle/volto/tests/test_resolveuid_re_patch.py b/src/redturtle/volto/tests/test_resolveuid_re_patch.py index bf9bb417..ec916706 100644 --- a/src/redturtle/volto/tests/test_resolveuid_re_patch.py +++ b/src/redturtle/volto/tests/test_resolveuid_re_patch.py @@ -1,13 +1,12 @@ # -*- coding: utf-8 -*- -import unittest - from plone import api -from plone.app.testing import TEST_USER_ID from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID from plone.restapi.serializer.utils import uid_to_url - from redturtle.volto.testing import REDTURTLE_VOLTO_FUNCTIONAL_TESTING +import unittest + class TestRESOLVEUIDREPatch(unittest.TestCase): layer = REDTURTLE_VOLTO_FUNCTIONAL_TESTING diff --git a/src/redturtle/volto/tests/test_service_context_navigation.py b/src/redturtle/volto/tests/test_service_context_navigation.py index a7406d5f..00fd7c60 100644 --- a/src/redturtle/volto/tests/test_service_context_navigation.py +++ b/src/redturtle/volto/tests/test_service_context_navigation.py @@ -1,16 +1,15 @@ # -*- coding: utf-8 -*- -import unittest - -import transaction from plone import api +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles from plone.restapi.testing import RelativeSession - from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import transaction +import unittest + class TestServicesContextNavigation(unittest.TestCase): layer = REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING diff --git a/src/redturtle/volto/tests/test_service_sitemap.py b/src/redturtle/volto/tests/test_service_sitemap.py index 4810a6d2..0171dc29 100644 --- a/src/redturtle/volto/tests/test_service_sitemap.py +++ b/src/redturtle/volto/tests/test_service_sitemap.py @@ -1,15 +1,14 @@ # -*- coding: utf-8 -*- -import unittest - from plone import api +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles from plone.restapi.testing import RelativeSession +from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING from transaction import commit -from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import unittest class TestServicesSitemap(unittest.TestCase): diff --git a/src/redturtle/volto/tests/test_setup.py b/src/redturtle/volto/tests/test_setup.py index 8ebb38ef..3db707e9 100644 --- a/src/redturtle/volto/tests/test_setup.py +++ b/src/redturtle/volto/tests/test_setup.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- """Setup tests for this package.""" -import unittest - from plone import api -from plone.app.testing import TEST_USER_ID from plone.app.testing import setRoles - +from plone.app.testing import TEST_USER_ID from redturtle.volto.testing import REDTURTLE_VOLTO_INTEGRATION_TESTING # noqa: E501 +import unittest + + try: from Products.CMFPlone.utils import get_installer except ImportError: @@ -37,7 +37,6 @@ def test_product_installed(self): def test_browserlayer(self): """Test that IRedturtleVoltoLayer is registered.""" from plone.browserlayer import utils - from redturtle.volto.interfaces import IRedturtleVoltoLayer self.assertIn(IRedturtleVoltoLayer, utils.registered_layers()) @@ -80,7 +79,6 @@ def test_product_uninstalled(self): def test_browserlayer_removed(self): """Test that IRedturtleVoltoLayer is removed.""" from plone.browserlayer import utils - from redturtle.volto.interfaces import IRedturtleVoltoLayer self.assertNotIn(IRedturtleVoltoLayer, utils.registered_layers()) diff --git a/src/redturtle/volto/tests/test_site_search.py b/src/redturtle/volto/tests/test_site_search.py index f06d5f57..b5f5b718 100644 --- a/src/redturtle/volto/tests/test_site_search.py +++ b/src/redturtle/volto/tests/test_site_search.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- -import unittest - from plone import api +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles from plone.registry.interfaces import IRegistry from plone.restapi.testing import RelativeSession from Products.CMFPlone.interfaces import ISearchSchema +from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING from transaction import commit from zope.component import getUtility -from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import unittest class SiteSearchTest(unittest.TestCase): diff --git a/src/redturtle/volto/tests/test_summary_customization.py b/src/redturtle/volto/tests/test_summary_customization.py index ee96e480..535056a0 100644 --- a/src/redturtle/volto/tests/test_summary_customization.py +++ b/src/redturtle/volto/tests/test_summary_customization.py @@ -1,18 +1,17 @@ # -*- coding: utf-8 -*- -import os -import unittest - -import transaction from plone import api +from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME from plone.app.testing import SITE_OWNER_PASSWORD from plone.app.testing import TEST_USER_ID -from plone.app.testing import setRoles from plone.namedfile.file import NamedBlobImage from plone.restapi.testing import RelativeSession - from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import os +import transaction +import unittest + class TestSummaryCustomization(unittest.TestCase): layer = REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING diff --git a/src/redturtle/volto/tests/test_vocabulary_endpoint.py b/src/redturtle/volto/tests/test_vocabulary_endpoint.py index a7825991..59634e88 100644 --- a/src/redturtle/volto/tests/test_vocabulary_endpoint.py +++ b/src/redturtle/volto/tests/test_vocabulary_endpoint.py @@ -1,14 +1,13 @@ # -*- coding: utf-8 -*- -import unittest - -import transaction from plone import api -from plone.app.testing import TEST_USER_ID from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID from plone.restapi.testing import RelativeSession - from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +import transaction +import unittest + class TestVocabularyEndpoint(unittest.TestCase): layer = REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING diff --git a/src/redturtle/volto/types/adapters.py b/src/redturtle/volto/types/adapters.py index d7e53883..286b6a53 100644 --- a/src/redturtle/volto/types/adapters.py +++ b/src/redturtle/volto/types/adapters.py @@ -2,15 +2,14 @@ """JsonSchema providers.""" from plone.restapi.types.adapters import TextLineJsonSchemaProvider as Base from plone.restapi.types.interfaces import IJsonSchemaProvider +from redturtle.volto import _ +from redturtle.volto.interfaces import IRedturtleVoltoLayer from zope.component import adapter from zope.i18n import translate -from zope.interface import Interface from zope.interface import implementer +from zope.interface import Interface from zope.schema.interfaces import ITextLine -from redturtle.volto import _ -from redturtle.volto.interfaces import IRedturtleVoltoLayer - @adapter(ITextLine, Interface, IRedturtleVoltoLayer) @implementer(IJsonSchemaProvider) diff --git a/src/redturtle/volto/upgrades.py b/src/redturtle/volto/upgrades.py index 726e832c..ff45e9d1 100644 --- a/src/redturtle/volto/upgrades.py +++ b/src/redturtle/volto/upgrades.py @@ -1,16 +1,18 @@ # -*- coding: utf-8 -*- -import json -import logging -from copy import deepcopy -from uuid import uuid4 - from Acquisition import aq_base +from copy import deepcopy from plone import api from plone.app.upgrade.utils import installOrReinstallProduct from plone.dexterity.utils import iterSchemata from plone.restapi.behaviors import IBlocks +from redturtle.volto.setuphandlers import remove_custom_googlebot +from uuid import uuid4 from zope.schema import getFields +import json +import logging + + try: from collective.volto.blocksfield.field import BlocksField @@ -472,3 +474,23 @@ def to_4301(context): for brain in brains: event = brain.getObject() event.reindexObject(idxs=["start"]) + + +def to_4302(context): + remove_custom_googlebot(context) + + brains = api.content.find(portal_type="Event") + logger.info("Reindexing {} Events".format(len(brains))) + + for brain in brains: + event = brain.getObject() + event.reindexObject(idxs=["start", "end"]) + + +def to_4303(context): + brains = api.content.find(portal_type="Event") + logger.info("Reindexing {} Events".format(len(brains))) + + for brain in brains: + event = brain.getObject() + event.reindexObject(idxs=["start", "end"]) diff --git a/src/redturtle/volto/upgrades.zcml b/src/redturtle/volto/upgrades.zcml index 2aa7f684..ff5d3b20 100644 --- a/src/redturtle/volto/upgrades.zcml +++ b/src/redturtle/volto/upgrades.zcml @@ -190,7 +190,7 @@ /> + + + + diff --git a/test_plone52.cfg b/test_plone52.cfg index 6ba6acd4..f6946551 100644 --- a/test_plone52.cfg +++ b/test_plone52.cfg @@ -14,7 +14,7 @@ plone.app.versioningbehavior = 1.4.6 plone.app.vocabularies = 4.3.0 plone.patternslib = 1.1.1 plone.rest = 2.0.0 -plone.restapi = 8.43.3 +plone.restapi = 9.6.0 plone.volto = 4.0.0 pycountry = 19.8.18 collective.purgebyid = 1.1.1 @@ -31,11 +31,3 @@ pyflakes = 2.3.1 createcoverage = 1.5 mccabe = 0.6.1 plone.recipe.codeanalysis = 3.0.1 - - -# Added by buildout at 2023-03-11 19:27:39.625210 -kitconcept.seo = 2.0.1 - -# Required by: -# redturtle.volto==4.1.4.dev0 -collective.volto.cookieconsent = 1.1.1 diff --git a/test_plone60.cfg b/test_plone60.cfg index 1c1f0217..241cc1e3 100644 --- a/test_plone60.cfg +++ b/test_plone60.cfg @@ -5,8 +5,6 @@ extends = https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg base.cfg -update-versions-file = test_plone60.cfg - [versions] # Added by buildout at 2023-03-10 11:55:21.122842 @@ -19,57 +17,4 @@ plone.recipe.codeanalysis = 3.0.1 pycodestyle = 2.10.0 pyflakes = 3.0.1 plone.stringinterp = 2.0.0 - -# Added by buildout at 2023-03-11 19:16:55.437411 -bleach = 6.0.0 -build = 0.1.0 -coverage = 7.2.1 -i18ndude = 5.5.0 -keyring = 23.13.1 -kitconcept.seo = 2.0.1 -markdown-it-py = 2.2.0 -mdurl = 0.1.2 -pep517 = 0.9.1 -pkginfo = 1.9.6 -readme-renderer = 37.3 -requests-toolbelt = 0.10.1 -rfc3986 = 2.0.0 -rich = 13.3.2 -twine = 4.0.2 -zest.releaser = 7.3.0 - -# Required by: -# plone.recipe.codeanalysis==3.0.1 -check-manifest = 0.49 - -# Required by: -# redturtle.volto==4.1.4.dev0 -collective.purgebyid = 1.2.1 - -# Required by: -# redturtle.volto==4.1.4.dev0 -collective.volto.cookieconsent = 1.1.1 - -# Required by: -# zest.releaser==7.3.0 -colorama = 0.4.6 - -# Required by: -# keyring==23.13.1 -jaraco.classes = 3.2.3 - -# Required by: -# jaraco.classes==3.2.3 -more-itertools = 9.1.0 - -# Required by: -# check-manifest==0.49 -tomli = 2.0.1 - -# Required by: -# bleach==6.0.0 -webencodings = 0.5.1 - -# Required by: -# kitconcept.seo==2.0.1 -z3c.jbot = 1.1.1 +plone.restapi = >=9.6.0