Skip to content

Commit

Permalink
Merge branch 'master' into rer_staging
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Mar 11, 2024
2 parents da2913d + 779b021 commit 25b676b
Show file tree
Hide file tree
Showing 55 changed files with 359 additions and 281 deletions.
3 changes: 1 addition & 2 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[settings]
profile=black
force_single_line = true
profile=plone
43 changes: 42 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
------------------

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from setuptools import find_packages
from setuptools import setup


long_description = "\n\n".join(
[
open("README.rst").read(),
Expand All @@ -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/
Expand Down Expand Up @@ -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={
Expand Down
11 changes: 3 additions & 8 deletions src/redturtle/volto/__init__.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down Expand Up @@ -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/([^/]*)/?(.*)$")
9 changes: 6 additions & 3 deletions src/redturtle/volto/adapters/blocks_linkintegrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/redturtle/volto/adapters/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,22 @@
provides="plone.restapi.interfaces.IBlockFieldLinkIntegrityRetriever"
/>
</configure>


<adapter
factory=".rss.EventItem"
provides="plone.base.interfaces.syndication.IFeedItem"
for="plone.app.contenttypes.interfaces.IEvent
plone.base.interfaces.syndication.IFeed"
zcml:condition="have plone-60"
/>

<adapter
factory=".rss.EventItem"
provides="Products.CMFPlone.interfaces.syndication.IFeedItem"
for="plone.app.contenttypes.interfaces.IEvent
Products.CMFPlone.interfaces.syndication.IFeed"
zcml:condition="not-have plone-60"
/>

</configure>
24 changes: 24 additions & 0 deletions src/redturtle/volto/adapters/rss.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion src/redturtle/volto/adapters/stringinterp.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion src/redturtle/volto/browser/controlpanel.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
9 changes: 5 additions & 4 deletions src/redturtle/volto/browser/find_blocks.py
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
13 changes: 7 additions & 6 deletions src/redturtle/volto/browser/fix_links.py
Original file line number Diff line number Diff line change
@@ -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__)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<tal:block tal:repeat="item item/categories">
<dc:subject tal:content="item">Item</dc:subject>
</tal:block>
<dc:date tal:content="item/published/HTML4|item/modified/HTML4">Published or last modified date if no published date</dc:date>
<dc:date tal:content="item/startdate/HTML4|item/published/HTML4|item/modified/HTML4">Published or last modified date if no published date</dc:date>
<dc:type tal:content="item/context/portal_type">Type</dc:type>
</item>
</tal:block>
Expand Down
4 changes: 2 additions & 2 deletions src/redturtle/volto/browser/sitemap.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- 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
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.interfaces import IPloneSiteRoot
from zope.component import getUtility

import datetime


class SiteMapView(LayoutSiteMapView):
def objects(self):
Expand Down
1 change: 1 addition & 0 deletions src/redturtle/volto/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os


MAX_LIMIT = int(os.environ.get("REDTURTLE_VOLTO_MAX_LIMIT_SEARCH") or 500)
3 changes: 1 addition & 2 deletions src/redturtle/volto/interfaces.py
Original file line number Diff line number Diff line change
@@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion src/redturtle/volto/locales/update.py
Original file line number Diff line number Diff line change
@@ -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, ""))
Expand Down
32 changes: 20 additions & 12 deletions src/redturtle/volto/monkey.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/redturtle/volto/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<version>4301</version>
<version>4303</version>
<dependencies>
<dependency>profile-plone.volto:default</dependency>
<dependency>profile-plone.app.caching:with-caching-proxy</dependency>
Expand Down
Loading

0 comments on commit 25b676b

Please sign in to comment.