Skip to content

Commit

Permalink
Merge branch 'main' into cleanupbefore4.0.0
Browse files Browse the repository at this point in the history
* main:
  Remove c.folderishtypes dependency. (#36)
  • Loading branch information
sneridagh committed Jan 19, 2022
2 parents 0b82a08 + 102ffa8 commit 551371a
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Changelog
3.1.0a9 (2022-01-15)
--------------------

Breaking:

- Remove c.folderishtypes dependency

New Feature:

- Add new field in the coresandbox: not constrained by vocabulary field but the vocabulary defined in the widget.
[sneridagh]

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def readfile(name):
"Products.GenericSetup",
"setuptools",
"plone.restapi>=8.13.0",
"collective.folderishtypes[dexterity]",
"plone.app.vocabularies>=4.3.0",
],
extras_require={
Expand Down
24 changes: 24 additions & 0 deletions src/plone/volto/content.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from plone.volto.interfaces import IFolderishDocument
from plone.volto.interfaces import IFolderishEvent
from plone.volto.interfaces import IFolderishNewsItem
from plone.app.contenttypes.interfaces import IDocument
from plone.app.contenttypes.interfaces import IEvent
from plone.app.contenttypes.interfaces import INewsItem
from plone.dexterity.content import Container
from zope.interface import implementer


@implementer(IDocument, IFolderishDocument)
class FolderishDocument(Container):
pass


@implementer(IEvent, IFolderishEvent)
class FolderishEvent(Container):
pass


@implementer(INewsItem, IFolderishNewsItem)
class FolderishNewsItem(Container):
pass
1 change: 0 additions & 1 deletion src/plone/volto/dependencies.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@
/>
<include package="plone.restapi" />
<include package="plone.api" />
<include package="collective.folderishtypes" />

</configure>
20 changes: 20 additions & 0 deletions src/plone/volto/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class IPloneVoltoCoreLayer(IDefaultBrowserLayer):
"""Marker interface that defines a browser layer."""


class IThemeSpecific(IPloneVoltoCoreLayer):
"""bbb for collective.folderishtypes browser interface."""


class IVoltoSettings(Interface):
"""Volto settings necessary to store in the backend"""

Expand All @@ -17,3 +21,19 @@ class IVoltoSettings(Interface):
description=u"Used for rewriting URL's sent in the password reset e-mail by Plone.",
default="http://localhost:3000",
)


class IFolderishType(Interface):
"""Marker interface"""


class IFolderishDocument(IFolderishType):
"""Marker interface"""


class IFolderishEvent(IFolderishType):
"""Marker interface"""


class IFolderishNewsItem(IFolderishType):
"""Marker interface"""
13 changes: 13 additions & 0 deletions src/plone/volto/patches.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from plone.app.upgrade.utils import alias_module
from plone.volto import logger
from plone.volto import content
from plone.volto import interfaces
from plone.volto.interfaces import IVoltoSettings
from plone.registry.interfaces import IRegistry
from plone.rest.interfaces import IAPIRequest
Expand All @@ -12,6 +16,15 @@
LOG = logging.getLogger("Zope.SiteErrorLog")


try:
from collective.folderishtypes.dx import content # noqa F401
except ImportError:
logger.info("Aliasing collective.folderish classes to plone.volto classes.")
alias_module("collective.folderishtypes.dx.content", content)
alias_module("collective.folderishtypes.dx.interfaces", interfaces)
alias_module("collective.folderishtypes.interfaces", interfaces)


def _do_copy_to_zlog(self, now, strtype, entry_id, url, tb_text):
when = _rate_restrict_pool.get(strtype, 0)
if now > when:
Expand Down
3 changes: 1 addition & 2 deletions src/plone/volto/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<version>1013</version>
<version>1015</version>
<dependencies>
<dependency>profile-collective.folderishtypes.dx:default</dependency>
<dependency>profile-plone.restapi:blocks</dependency>
</dependencies>
</metadata>
2 changes: 2 additions & 0 deletions src/plone/volto/profiles/default/types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
<object meta_type="Dexterity FTI" name="LRF" />
<object meta_type="Dexterity FTI" name="Document" />
<object meta_type="Dexterity FTI" name="Collection" />
<object meta_type="Dexterity FTI" name="News Item" />
<object meta_type="Dexterity FTI" name="Event" />
</object>
4 changes: 4 additions & 0 deletions src/plone/volto/profiles/default/types/Document.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
name="Document"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">

<property name="filter_content_types">False</property>
<property name="klass">plone.volto.content.FolderishDocument</property>

<!-- Enabled behaviors -->
<property name="behaviors">
<element value="plone.constraintypes"/>
<element value="plone.namefromtitle" />
<element value="plone.allowdiscussion" />
<element value="plone.excludefromnavigation" />
Expand Down
9 changes: 9 additions & 0 deletions src/plone/volto/profiles/default/types/Event.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<object name="Event" meta_type="Dexterity FTI" i18n:domain="plone"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="filter_content_types">False</property>
<property name="klass">plone.volto.content.FolderishEvent</property>
<property name="behaviors" purge="false">
<element value="plone.constraintypes"/>
</property>
</object>
9 changes: 9 additions & 0 deletions src/plone/volto/profiles/default/types/News_Item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<object name="News Item" meta_type="Dexterity FTI" i18n:domain="plone"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<property name="filter_content_types">False</property>
<property name="klass">plone.volto.content.FolderishNewsItem</property>
<property name="behaviors" purge="false">
<element value="plone.constraintypes"/>
</property>
</object>
34 changes: 34 additions & 0 deletions src/plone/volto/upgrades.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
from copy import deepcopy
from plone import api
from plone.restapi.behaviors import IBlocks
from plone.volto import content
from plone.volto import logger
from plone.volto.setuphandlers import NO_RICHTEXT_BEHAVIOR_CONTENT_TYPES
from plone.volto.setuphandlers import remove_behavior


MIGRATION = {
"Document": content.FolderishDocument,
"Event": content.FolderishEvent,
"News Item": content.FolderishNewsItem,
}


def migrate_content_classes(context):
"""Migrate content created with collective.folderishtypes to plone.volto."""
interface = "collective.folderishtypes.interfaces.IFolderishType"
idxs = [
"object_provides",
]
brains = api.content.find(object_provides=interface)
total_brains = len(brains)
logger.info(f"Migration: {total_brains} contents to be migrated.")
for idx, brain in enumerate(brains):
content = brain.getObject()
content_id = content.getId()
content.__class__ = MIGRATION[content.portal_type]
parent = content.aq_parent
parent._delOb(content_id)
parent._setOb(content_id, content)
content = parent[content_id]
content.reindexObject(idxs=idxs)

if idx and idx % 100 == 0:
logger.info(f"Migration: {idx + 1} / {total_brains}")

logger.info("Migration from collective.folderishtypes to plone.volto complete")


def from12to13_migrate_listings(context):
def migrate_listing(originBlocks):
blocks = deepcopy(originBlocks)
Expand Down
18 changes: 17 additions & 1 deletion src/plone/volto/upgrades.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,26 @@
import_steps="catalog"
/>

<genericsetup:upgradeSteps
<genericsetup:upgradeDepends
title="Move from c.folderishtypes to local"
profile="plone.volto:default"
source="1012"
destination="1013"
import_steps="typeinfo"
/>

<genericsetup:upgradeStep
title="Migrate existing content classes from old c.folderishtypes to local"
profile="plone.volto:default"
source="1013"
destination="1014"
handler=".upgrades.migrate_content_classes"
/>

<genericsetup:upgradeSteps
profile="plone.volto:default"
source="1014"
destination="1015"
>
<genericsetup:upgradeDepends
title="Update types info for Plone Site"
Expand Down

0 comments on commit 551371a

Please sign in to comment.