From a3f9160a93a60f3ae817dbc138018ef6bdffd3a9 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Wed, 17 May 2023 15:41:38 +0200 Subject: [PATCH 01/36] Turn this into a core addon, sync with CMFPlone, make installable and remove old files --- plone/app/discussion/TODO.txt | 100 ------------------ plone/app/discussion/configure.zcml | 2 +- .../profiles/default/portal_atct.xml | 39 ------- .../default/types/Discussion_Item.xml | 24 +++-- setup.py | 58 +++++----- 5 files changed, 50 insertions(+), 173 deletions(-) delete mode 100644 plone/app/discussion/TODO.txt delete mode 100644 plone/app/discussion/profiles/default/portal_atct.xml diff --git a/plone/app/discussion/TODO.txt b/plone/app/discussion/TODO.txt deleted file mode 100644 index 30a1031e..00000000 --- a/plone/app/discussion/TODO.txt +++ /dev/null @@ -1,100 +0,0 @@ -========================== -plone.app.discussion to-do -========================== - - [ ] Add BBB support for the existing portal_discussion interface - - - implement in BBB package - - mix into tool.CommentingTool - - emit deprecation warnings - -MINOR/FUTURE RELEASES: ----------------------- - - [ ] During recursive deletion of child comments, events are fired when the - conversation data structures may be in an inconsistent state. We need - some tests for this, and possibly some different handling of those - events. - - [ ] Ajaxify adding and deleting comments in the comments viewlet. - - [ ] Rebuild the zebra table after batch deleting/publishing - - [ ] Replace the comment_review_workflow - - [ ] Thread building in conversation.getThreads() - - [ ] Batching in conversation.getComments() - - -DONE: ------ - - [X] Make sure a catalog Clear & Rebuild doesn't lose all comments - - [X] Add UI - - - comment forms should use z3c.form subforms and plone.z3cform's - ExtensibleForm support - - [X] Implement plone.indexer indexers for comments, filling standard metadata - - - Note discrepancy between Python datetime and indexing expecting a Zope 2 - DateTime field - - [X] Implement plone.indexer indexers for commented-upon content - - - Unique set of commentators - - Number of comments - - Date/time of most recent comment - - These have to be reindexed when comment is added/removed - (IContainerModifiedEvent). They also need to be set up in catalog.xml. - - [X] Add jQuery auto-resize to comment text field - http://www.aclevercookie.com/demos/autogrow_textarea.html - - [X] Add event handlers to ensure we don't get stale comments in the catalog - when parent objects are removed/moved/cloned: - - - Create the conversation when an object is created - - Dispatch object added/removed/moved/cloned events to conversations - - Dispatch conversation added/removed/moved/cloned events to comments - - [X] Add tests for conversation dict API - - [X] Add tests for IReplies adapters - - [X] Add control panel - - - install plone.registry records using registry.xml - - create control panel using helper class in plone.app.registry - - [X] Discussion Control Panel: Add icon - - [X] Add id fall back for Creator if no Username (Title) has been added - - [X] Replace the reply-to-comment button with a Plone-like reply-button - - [X] IE: cancel button in reply-to-comment form does not work - - [X] Chrome (Linux): Reply to comment is not working - (TypeError: long() argument must be a string or a number) - - [X] Restrict nesting of comments on a certain level - - [X] Fix temporary commenter's image css - - [X] Make comments viewlet format_time return localized time - - [X] Add i18n translations - - [X] Add i18n translations for author_username and author_email - - [X] Plone reports "unsuccessfully attempted to uncatalog an object" while - trying to delete a comment. - - [X] Fix that when opening a reply form before the page has been fully loaded, - the reply layer is closed again. - - [X] Form validation is not working in the reply-to-comment form \ No newline at end of file diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index e2b82f2d..63ae743c 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -40,7 +40,7 @@ - - - - - - ATCurrentAuthorCriterion - ATSimpleStringCriterion - ATListCriterion - - - - - - ATSimpleIntCriterion - - - - - - - - - - diff --git a/plone/app/discussion/profiles/default/types/Discussion_Item.xml b/plone/app/discussion/profiles/default/types/Discussion_Item.xml index c05efcb9..31be160f 100644 --- a/plone/app/discussion/profiles/default/types/Discussion_Item.xml +++ b/plone/app/discussion/profiles/default/types/Discussion_Item.xml @@ -9,8 +9,9 @@ >Comment Comments added to a content item. - discussionitem_icon.png + >Discussion Items are documents which reply to other content. + They should *not* be addable through the standard 'folder_factories' interface. + string:${portal_url}/discussionitem_icon.png Discussion Item plone.Comment @@ -18,20 +19,31 @@ False True - True + False + + + diff --git a/setup.py b/setup.py index 3b94f76a..661a9df1 100644 --- a/setup.py +++ b/setup.py @@ -3,33 +3,12 @@ from setuptools import setup -version = "4.1.3.dev0" +version = "5.0.0.dev0" long_description = ( f"{Path('README.rst').read_text()}\n{Path('CHANGES.rst').read_text()}" ) -install_requires = [ - "BTrees", - "Products.GenericSetup", - "Products.ZCatalog", - "Products.statusmessages", - "persistent", - "plone.api", - "plone.app.event", - "plone.registry", - "plone.resource", - "plone.uuid", - "zope.annotation", - "setuptools", - "plone.app.layout", - "plone.app.registry", - "plone.app.uuid", - "plone.base", - "plone.indexer", - "plone.z3cform", - "z3c.form>=2.3.3", -] setup( name="plone.app.discussion", @@ -43,16 +22,15 @@ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Plone", - "Framework :: Plone :: 6.0", + "Framework :: Plone :: 6.1", "Framework :: Plone :: Core", "Framework :: Zope :: 5", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], keywords="plone discussion", author="Timo Stollenwerk - Plone Foundation", @@ -63,8 +41,30 @@ namespace_packages=["plone", "plone.app"], include_package_data=True, zip_safe=False, - python_requires=">=3.8", - install_requires=install_requires, + python_requires=">=3.10", + install_requires=[ + "Products.CMFPlone", + "BTrees", + "Products.GenericSetup", + "Products.ZCatalog", + "Products.statusmessages", + "persistent", + "plone.api", + "plone.app.event", + "plone.dexterity", + "plone.registry", + "plone.resource", + "plone.uuid", + "zope.annotation", + "setuptools", + "plone.app.layout", + "plone.app.registry", + "plone.app.uuid", + "plone.base", + "plone.indexer", + "plone.z3cform", + "z3c.form>=2.3.3", + ], extras_require={ "test": [ "plone.app.testing", @@ -82,4 +82,8 @@ "python-dateutil", ], }, + entry_points=""" + [z3c.autoinclude.plugin] + target = plone + """, ) From 82328bea918d338ead86937bd47a977128628627 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Tue, 6 Jun 2023 18:11:38 +0200 Subject: [PATCH 02/36] move behavior here --- plone/app/discussion/behavior.py | 39 +++++++ plone/app/discussion/behavior.zcml | 21 ++++ plone/app/discussion/configure.zcml | 1 + .../functional_test_behavior_discussion.rst | 106 ++++++++++++++++++ plone/app/discussion/tests/test_functional.py | 1 + 5 files changed, 168 insertions(+) create mode 100644 plone/app/discussion/behavior.py create mode 100644 plone/app/discussion/behavior.zcml create mode 100644 plone/app/discussion/tests/functional_test_behavior_discussion.rst diff --git a/plone/app/discussion/behavior.py b/plone/app/discussion/behavior.py new file mode 100644 index 00000000..bdc2d8d8 --- /dev/null +++ b/plone/app/discussion/behavior.py @@ -0,0 +1,39 @@ +from plone.app.dexterity import _ +from plone.autoform import directives +from plone.autoform.interfaces import IFormFieldProvider +from plone.supermodel import model +from z3c.form.interfaces import IAddForm +from z3c.form.interfaces import IEditForm +from zope import schema +from zope.interface import provider +from zope.schema.vocabulary import SimpleTerm +from zope.schema.vocabulary import SimpleVocabulary + + +options = SimpleVocabulary( + [ + SimpleTerm(value=True, title=_("Yes")), + SimpleTerm(value=False, title=_("No")), + ] +) + + +@provider(IFormFieldProvider) +class IAllowDiscussion(model.Schema): + model.fieldset( + "settings", + label=_("Settings"), + fields=["allow_discussion"], + ) + + allow_discussion = schema.Choice( + title=_("Allow discussion"), + description=_("Allow discussion for this content object."), + vocabulary=options, + required=False, + default=None, + ) + + directives.omitted("allow_discussion") + directives.no_omit(IEditForm, "allow_discussion") + directives.no_omit(IAddForm, "allow_discussion") diff --git a/plone/app/discussion/behavior.zcml b/plone/app/discussion/behavior.zcml new file mode 100644 index 00000000..b921a5e4 --- /dev/null +++ b/plone/app/discussion/behavior.zcml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index 63ae743c..1553f07a 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -15,6 +15,7 @@ + diff --git a/plone/app/discussion/tests/functional_test_behavior_discussion.rst b/plone/app/discussion/tests/functional_test_behavior_discussion.rst new file mode 100644 index 00000000..6b247cfa --- /dev/null +++ b/plone/app/discussion/tests/functional_test_behavior_discussion.rst @@ -0,0 +1,106 @@ +Allow Discussion +================ + +Test Setup +---------- + +We create a dexterity content type that provides the allow discussion behavior:: + + >>> portal = layer['portal'] + >>> from plone.dexterity.fti import DexterityFTI + >>> fti = DexterityFTI('discussiondocument') + >>> fti.behaviors = ('plone.app.dexterity.behaviors.discussion.IAllowDiscussion',) + >>> portal.portal_types._setObject('discussiondocument', fti) + 'discussiondocument' + +Set up a test browser:: + + >>> from plone.app.testing import TEST_USER_ID, TEST_USER_NAME, TEST_USER_PASSWORD, setRoles + >>> setRoles(portal, TEST_USER_ID, ['Manager']) + >>> import transaction; transaction.commit() + >>> from plone.testing.zope import Browser + >>> browser = Browser(layer['app']) + >>> browser.addHeader('Authorization', 'Basic %s:%s' % (TEST_USER_NAME, TEST_USER_PASSWORD,)) + +We have to make sure the request provides IDiscussonLayer because the enabled +method on the conversation calls conversation_view (which is only registered +for IDiscussionLayer). + + >>> from plone.app.discussion.interfaces import IDiscussionLayer + >>> from zope.interface import alsoProvides + >>> alsoProvides(portal.REQUEST, IDiscussionLayer) + +Add a document:: + + >>> browser.open('http://nohost/plone/++add++discussiondocument') + + +Default Allow Discussion Options +-------------------------------- + +There are three options for the allow discussion select field:: + + >>> allowDiscussion = browser.getControl('Allow discussion') + >>> allowDiscussion.options + ['--NOVALUE--', 'True', 'False'] + +By default, no value is set for allow discussion:: + + >>> browser.getControl('Allow discussion').value + ['--NOVALUE--'] + >>> browser.getControl('Save').click() + >>> browser.url + 'http://nohost/plone/discussiondocument/view' + +This means discussion is not enabled: + + >>> from plone.app.discussion.interfaces import IConversation + >>> conv = IConversation(portal.discussiondocument) + >>> conv.enabled() + False + +We have to globally enable discussion in order to be able to add comments:: + + >>> from plone.registry.interfaces import IRegistry + >>> from zope.component import queryUtility + >>> from plone.app.discussion.interfaces import IDiscussionSettings + >>> registry = queryUtility(IRegistry) + >>> settings = registry.forInterface(IDiscussionSettings) + >>> settings.globally_enabled = True + +Discussion is still disabled for our content object though:: + + >>> from plone.app.discussion.interfaces import IConversation + >>> conv = IConversation(portal.discussiondocument) + >>> conv.enabled() + False + +This is because discussion is disabled by default for the document content +type:: + + >>> fti.allow_discussion + False + +If we allow discussion for the 'Document' content type, the conversation +for our content object is enabled because it just uses the default setting +(because allow_discussion is set to None):: + + >>> fti.allow_discussion = True + >>> from plone.app.discussion.interfaces import IConversation + >>> conv = IConversation(portal.discussiondocument) + >>> conv.enabled() + True + +We can now override the default value (True) by explicitly setting allow discussion to False:: + + >>> browser.open('http://nohost/plone/discussiondocument/edit') + >>> allowDiscussion = browser.getControl('Allow discussion') + >>> allowDiscussion.value = ['False'] + >>> browser.getControl('Save').click() + +Discussion on our content object is now not enabled:: + + >>> from plone.app.discussion.interfaces import IConversation + >>> conv = IConversation(portal.discussiondocument) + >>> conv.enabled() + False diff --git a/plone/app/discussion/tests/test_functional.py b/plone/app/discussion/tests/test_functional.py index b4ce3f0e..a9090a0a 100644 --- a/plone/app/discussion/tests/test_functional.py +++ b/plone/app/discussion/tests/test_functional.py @@ -17,6 +17,7 @@ normal_testfiles = [ "functional_test_comments.txt", "functional_test_comment_review_workflow.txt", + "functional_test_behavior_discussion.rst", ] From ae0e9a1cc90b85dc3371c93f452f586a99e1e6a2 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Tue, 6 Jun 2023 18:53:54 +0200 Subject: [PATCH 03/36] tune behavior and install it --- plone/app/discussion/behavior.zcml | 6 +++-- plone/app/discussion/configure.zcml | 1 + .../discussion/profiles/default/metadata.xml | 2 +- plone/app/discussion/setuphandlers.py | 26 +++++++++++++++++++ plone/app/discussion/upgrades.py | 8 +++++- plone/app/discussion/upgrades.zcml | 12 +++++++++ 6 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 plone/app/discussion/setuphandlers.py diff --git a/plone/app/discussion/behavior.zcml b/plone/app/discussion/behavior.zcml index b921a5e4..adfab872 100644 --- a/plone/app/discussion/behavior.zcml +++ b/plone/app/discussion/behavior.zcml @@ -12,10 +12,12 @@ diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index 1553f07a..f02f3ca0 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -43,6 +43,7 @@ name="default" title="Discussion Support" description="Commenting infrastructure for Plone" + post_handler=".setuphandlers.post_install" provides="Products.GenericSetup.interfaces.EXTENSION" for="plone.base.interfaces.IPloneSiteRoot" directory="profiles/default" diff --git a/plone/app/discussion/profiles/default/metadata.xml b/plone/app/discussion/profiles/default/metadata.xml index 38abca6d..4cad4f61 100644 --- a/plone/app/discussion/profiles/default/metadata.xml +++ b/plone/app/discussion/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 2001 + 2002 profile-plone.resource:default profile-plone.app.registry:default diff --git a/plone/app/discussion/setuphandlers.py b/plone/app/discussion/setuphandlers.py new file mode 100644 index 00000000..ed3e575d --- /dev/null +++ b/plone/app/discussion/setuphandlers.py @@ -0,0 +1,26 @@ +from Products.CMFCore.utils import getToolByName + + +DEFAULT_TYPES = [ + "Document", + "Event", + "File", + "Folder", + "Image", + "News Item", + "Collection", + "Link", +] + + +def add_discussion_behavior_to_default_types(context): + """Add the discussion behavior to all default types, if they exist.""" + types_tool = getToolByName(context, "portal_types") + for type_name in DEFAULT_TYPES: + if type_name in types_tool.objectIds(): + types_tool[type_name].behaviors += ("plone.allowdiscussion",) + + +def post_install(context): + """Post install script""" + add_discussion_behavior_to_default_types(context) diff --git a/plone/app/discussion/upgrades.py b/plone/app/discussion/upgrades.py index dc78ea76..e5f61dbd 100644 --- a/plone/app/discussion/upgrades.py +++ b/plone/app/discussion/upgrades.py @@ -1,6 +1,7 @@ +from .interfaces import IDiscussionSettings +from .setuphandlers import add_discussion_behavior_to_default_types from datetime import timezone from plone import api -from plone.app.discussion.interfaces import IDiscussionSettings from plone.registry.interfaces import IRegistry from Products.CMFCore.utils import getToolByName from Products.ZCatalog.ProgressHandler import ZLogHandler @@ -115,3 +116,8 @@ def set_timezone_on_dates(context): logger.info( "Updated %i creation dates and %i modification dates" % (creations, modifieds) ) + +def set_discussion_behavior(context): + """Add the discussion behavior to all default types, if they exist. + """ + add_discussion_behavior_to_default_types(context) diff --git a/plone/app/discussion/upgrades.zcml b/plone/app/discussion/upgrades.zcml index d265d428..e63f85d6 100644 --- a/plone/app/discussion/upgrades.zcml +++ b/plone/app/discussion/upgrades.zcml @@ -108,4 +108,16 @@ /> + + + + From b499f9bca1246ca45a104dad8e0daf9b1215933c Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Tue, 6 Jun 2023 19:01:11 +0200 Subject: [PATCH 04/36] fix behavior name usage --- .../discussion/tests/functional_test_behavior_discussion.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plone/app/discussion/tests/functional_test_behavior_discussion.rst b/plone/app/discussion/tests/functional_test_behavior_discussion.rst index 6b247cfa..f86925b4 100644 --- a/plone/app/discussion/tests/functional_test_behavior_discussion.rst +++ b/plone/app/discussion/tests/functional_test_behavior_discussion.rst @@ -9,7 +9,7 @@ We create a dexterity content type that provides the allow discussion behavior:: >>> portal = layer['portal'] >>> from plone.dexterity.fti import DexterityFTI >>> fti = DexterityFTI('discussiondocument') - >>> fti.behaviors = ('plone.app.dexterity.behaviors.discussion.IAllowDiscussion',) + >>> fti.behaviors = ('plone.allowdiscussion',) >>> portal.portal_types._setObject('discussiondocument', fti) 'discussiondocument' From 6378dce64db0c1b013041ea07ba114ae1b9f2da6 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Tue, 6 Jun 2023 19:17:52 +0200 Subject: [PATCH 05/36] fix one test and finetuning --- plone/app/discussion/architecture.txt | 10 +++++----- plone/app/discussion/behavior.py | 2 +- plone/app/discussion/design.txt | 18 +++++++++--------- ...mments.txt => functional_test_comments.rst} | 4 ++-- plone/app/discussion/tests/test_functional.py | 6 ++---- 5 files changed, 19 insertions(+), 21 deletions(-) rename plone/app/discussion/tests/{functional_test_comments.txt => functional_test_comments.rst} (99%) diff --git a/plone/app/discussion/architecture.txt b/plone/app/discussion/architecture.txt index f8026e38..5002ef0e 100644 --- a/plone/app/discussion/architecture.txt +++ b/plone/app/discussion/architecture.txt @@ -14,15 +14,15 @@ plone.app.discussion. content. **Discussion items are subject to workflow and permission** - Moderation, anonymous commenting, and auto approve/reject should be + Moderation, anonymous commenting, and auto-approve/reject should be handled using workflow states, automatic and manual transitions, and permissions. - **Discussion items are light weight objects** - Discussion item objects are as light weight as possible. Ideally, a + **Discussion items are lightweight objects** + Discussion item objects are as lightweight as possible. Ideally, a discussion item should be as lightweight as a catalog brain. This may mean that we forego convenience base classes and re-implement certain interfaces. - Comments should not provide the full set of dublin core metadata, though + Comments should not provide the full set of Dublin Core metadata, though custom indexers can be used to provide values for standard catalog indexes. **Optimise for retrieval speed** @@ -49,7 +49,7 @@ plone.app.discussion. **Discussion items are retrieved in reverse creation date order** Discussion items do not need to support explicit ordering. They should always be retrieved in reverse creation date order (most recent for). - They can be stored with keys so that this is always true. + They can be stored with keys so this is always true. **Discussion items do not need readable ids** Ids can be based on the creation date. diff --git a/plone/app/discussion/behavior.py b/plone/app/discussion/behavior.py index bdc2d8d8..9691f694 100644 --- a/plone/app/discussion/behavior.py +++ b/plone/app/discussion/behavior.py @@ -1,6 +1,6 @@ -from plone.app.dexterity import _ from plone.autoform import directives from plone.autoform.interfaces import IFormFieldProvider +from plone.base import PloneMessageFactory as _ from plone.supermodel import model from z3c.form.interfaces import IAddForm from z3c.form.interfaces import IEditForm diff --git a/plone/app/discussion/design.txt b/plone/app/discussion/design.txt index 11c75bd0..c5af0354 100644 --- a/plone/app/discussion/design.txt +++ b/plone/app/discussion/design.txt @@ -8,7 +8,7 @@ Storage and traversal --------------------- For each content item, there is a Conversation object stored in annotations. -This can be traversed to via the ++conversation++ namespace, but also fetched +This can be traversed via the ++conversation++ namespace, but also fetched via an adapter lookup to IConversation. The conversation stores all comments related to a content object. Each @@ -22,7 +22,7 @@ incremental. Ids must be positive integers - 0 or negative numbers are not allowed. Threading information is stored in the conversation: we keep track of the -set of children and the parent if any comment. Top-level comments have a +set of children and the parent if any comments. Top-level comments have a parent id of 0. This information is managed by the conversation class when comments are manipulated using a dict-like API. @@ -82,20 +82,20 @@ Thus, we want: * Traversable, to get absolute_url() and friends - this requires a good acquisition chain at all times - * Acquisition.Explicit, to support acquisition + * Acquisition.Explicit, to support the acquisition - we do not want implicit acquisition * Owned, to be able to track ownership * RoleManager, to support permissions and local roles We also want to use a number of custom indexers for most of the standard -metadata such as creator, effective date etc. +metadata such as creator, effective date, etc. Finally, we'll need event handlers to perform the actual indexing. Discussion settings ------------------- -Discussion can be enabled per-type and per-instance, via values in the FTI +Discussion can be enabled per type and per instance, via values in the FTI (allow_discussion) and on the object. These will remain unchanged. The IConversation object's 'enabled' property should consult these. @@ -117,7 +117,7 @@ Where possible, we should use existing permissions: * Modify Portal Content * Request Review -In addition, we'll need a 'Moderator' role and a moderation permission, +In addition, we'll need a 'Moderator' role and moderation permission, * Moderate comment * Bypass moderation @@ -137,11 +137,11 @@ These could work in a workflow like this: | | +----- {auto-moderate} ----+ -The 'posted' state is the initial state. 'published' is the state where the -comment is visible to non-reviewers. +The 'posted' state is the initial state. +'published', is the state where the comment is visible to non-reviewers. The 'publish' transition would be protected by the 'Moderate comment' -permission. We could have states and transition for 'rejected', etc, but it +permission. We could have states and transitions for 'rejected', etc, but it is probably just as good to delete comments that are rejected. The 'auto-publish' transition would be an automatic transition protected by diff --git a/plone/app/discussion/tests/functional_test_comments.txt b/plone/app/discussion/tests/functional_test_comments.rst similarity index 99% rename from plone/app/discussion/tests/functional_test_comments.txt rename to plone/app/discussion/tests/functional_test_comments.rst index 61ab4a3e..59d08782 100644 --- a/plone/app/discussion/tests/functional_test_comments.txt +++ b/plone/app/discussion/tests/functional_test_comments.rst @@ -163,8 +163,8 @@ Check if the comment has been added properly. True -Post a comment as anonymous user --------------------------------- +Post a comment as an anonymous user +----------------------------------- Login and post comment as Anonymous diff --git a/plone/app/discussion/tests/test_functional.py b/plone/app/discussion/tests/test_functional.py index a9090a0a..5a3813d7 100644 --- a/plone/app/discussion/tests/test_functional.py +++ b/plone/app/discussion/tests/test_functional.py @@ -1,9 +1,7 @@ """Functional Doctests for plone.app.discussion. - - These test are only triggered when Plone 4 (and plone.testing) is installed. """ -from ..testing import PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING # noqa +from ..testing import PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING from plone.testing import layered import doctest @@ -15,7 +13,7 @@ doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_ONLY_FIRST_FAILURE ) normal_testfiles = [ - "functional_test_comments.txt", + "functional_test_comments.rst", "functional_test_comment_review_workflow.txt", "functional_test_behavior_discussion.rst", ] From 798e2dc833cdebe96153df3453fef7faee0d1a99 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Thu, 13 Jul 2023 15:02:01 +0200 Subject: [PATCH 06/36] fix after merge of master --- setup.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 661a9df1..908d235e 100644 --- a/setup.py +++ b/setup.py @@ -3,16 +3,13 @@ from setuptools import setup -version = "5.0.0.dev0" - long_description = ( f"{Path('README.rst').read_text()}\n{Path('CHANGES.rst').read_text()}" ) - setup( name="plone.app.discussion", - version=version, + version="5.0.0.dev0", description="Enhanced discussion support for Plone", long_description=long_description, long_description_content_type="text/x-rst", From 018689d62adaadb52466f8081706567ab31de213 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Fri, 14 Jul 2023 16:32:17 +0200 Subject: [PATCH 07/36] add change log --- news/211.breaking | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 news/211.breaking diff --git a/news/211.breaking b/news/211.breaking new file mode 100644 index 00000000..f4cad3c5 --- /dev/null +++ b/news/211.breaking @@ -0,0 +1,4 @@ +Move this package in the space of Plone Core add-ons. +It now depends on Products.CMFPlone and is no longer installed by default. +It is still available in the default Plone distribution, but can be omitted in customizations. +[jensens] \ No newline at end of file From 1e74750f675407463e16a7bc51b383264f1bc8dc Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Fri, 14 Jul 2023 17:24:06 +0200 Subject: [PATCH 08/36] move check for 'Reply to item' permission from Products.CMFPlone here. --- .../app/discussion/tests/test_permissions.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 plone/app/discussion/tests/test_permissions.py diff --git a/plone/app/discussion/tests/test_permissions.py b/plone/app/discussion/tests/test_permissions.py new file mode 100644 index 00000000..ce14146b --- /dev/null +++ b/plone/app/discussion/tests/test_permissions.py @@ -0,0 +1,19 @@ +from ..testing import PLONE_APP_DISCUSSION_INTEGRATION_TESTING +from AccessControl.PermissionRole import rolesForPermissionOn + +import unittest + + +class PermissionsTest(unittest.TestCase): + """Make sure the permissions are set up properly.""" + + layer = PLONE_APP_DISCUSSION_INTEGRATION_TESTING + + def test_permissions_site_administrator_role(self): + # This integration test shows that the correct permissions were + # assigned to the Site Administrator role (whether inherited from the + # Zope application, or specified in the portal rolemap). + self.assertTrue( + "Site Administrator" + not in rolesForPermissionOn("Reply to item", self.layer["portal"]) + ) From 8b09087026d95a34e5c7916acdc2a6d2e730a6bc Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Wed, 15 May 2024 23:07:38 +0200 Subject: [PATCH 09/36] pre-commit fixes --- plone/app/discussion/behavior.zcml | 10 +++++----- plone/app/discussion/configure.zcml | 2 +- plone/app/discussion/upgrades.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plone/app/discussion/behavior.zcml b/plone/app/discussion/behavior.zcml index adfab872..6a3a26fc 100644 --- a/plone/app/discussion/behavior.zcml +++ b/plone/app/discussion/behavior.zcml @@ -3,7 +3,7 @@ xmlns:plone="http://namespaces.plone.org/plone" xmlns:zcml="http://namespaces.zope.org/zcml" i18n_domain="plone" -> + > diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index f02f3ca0..1a2e663b 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -43,10 +43,10 @@ name="default" title="Discussion Support" description="Commenting infrastructure for Plone" - post_handler=".setuphandlers.post_install" provides="Products.GenericSetup.interfaces.EXTENSION" for="plone.base.interfaces.IPloneSiteRoot" directory="profiles/default" + post_handler=".setuphandlers.post_install" /> diff --git a/plone/app/discussion/upgrades.py b/plone/app/discussion/upgrades.py index e5f61dbd..b63a666b 100644 --- a/plone/app/discussion/upgrades.py +++ b/plone/app/discussion/upgrades.py @@ -117,7 +117,7 @@ def set_timezone_on_dates(context): "Updated %i creation dates and %i modification dates" % (creations, modifieds) ) + def set_discussion_behavior(context): - """Add the discussion behavior to all default types, if they exist. - """ + """Add the discussion behavior to all default types, if they exist.""" add_discussion_behavior_to_default_types(context) From 63e6fbcf0651079ff06c0b9574397d931c318625 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Mon, 20 May 2024 21:08:13 +0200 Subject: [PATCH 10/36] move test from pa.dexterity to here --- .../discussion/tests/dexterity_discussion.rst | 106 ++++++++++++++++++ plone/app/discussion/tests/test_functional.py | 1 + 2 files changed, 107 insertions(+) create mode 100644 plone/app/discussion/tests/dexterity_discussion.rst diff --git a/plone/app/discussion/tests/dexterity_discussion.rst b/plone/app/discussion/tests/dexterity_discussion.rst new file mode 100644 index 00000000..f86925b4 --- /dev/null +++ b/plone/app/discussion/tests/dexterity_discussion.rst @@ -0,0 +1,106 @@ +Allow Discussion +================ + +Test Setup +---------- + +We create a dexterity content type that provides the allow discussion behavior:: + + >>> portal = layer['portal'] + >>> from plone.dexterity.fti import DexterityFTI + >>> fti = DexterityFTI('discussiondocument') + >>> fti.behaviors = ('plone.allowdiscussion',) + >>> portal.portal_types._setObject('discussiondocument', fti) + 'discussiondocument' + +Set up a test browser:: + + >>> from plone.app.testing import TEST_USER_ID, TEST_USER_NAME, TEST_USER_PASSWORD, setRoles + >>> setRoles(portal, TEST_USER_ID, ['Manager']) + >>> import transaction; transaction.commit() + >>> from plone.testing.zope import Browser + >>> browser = Browser(layer['app']) + >>> browser.addHeader('Authorization', 'Basic %s:%s' % (TEST_USER_NAME, TEST_USER_PASSWORD,)) + +We have to make sure the request provides IDiscussonLayer because the enabled +method on the conversation calls conversation_view (which is only registered +for IDiscussionLayer). + + >>> from plone.app.discussion.interfaces import IDiscussionLayer + >>> from zope.interface import alsoProvides + >>> alsoProvides(portal.REQUEST, IDiscussionLayer) + +Add a document:: + + >>> browser.open('http://nohost/plone/++add++discussiondocument') + + +Default Allow Discussion Options +-------------------------------- + +There are three options for the allow discussion select field:: + + >>> allowDiscussion = browser.getControl('Allow discussion') + >>> allowDiscussion.options + ['--NOVALUE--', 'True', 'False'] + +By default, no value is set for allow discussion:: + + >>> browser.getControl('Allow discussion').value + ['--NOVALUE--'] + >>> browser.getControl('Save').click() + >>> browser.url + 'http://nohost/plone/discussiondocument/view' + +This means discussion is not enabled: + + >>> from plone.app.discussion.interfaces import IConversation + >>> conv = IConversation(portal.discussiondocument) + >>> conv.enabled() + False + +We have to globally enable discussion in order to be able to add comments:: + + >>> from plone.registry.interfaces import IRegistry + >>> from zope.component import queryUtility + >>> from plone.app.discussion.interfaces import IDiscussionSettings + >>> registry = queryUtility(IRegistry) + >>> settings = registry.forInterface(IDiscussionSettings) + >>> settings.globally_enabled = True + +Discussion is still disabled for our content object though:: + + >>> from plone.app.discussion.interfaces import IConversation + >>> conv = IConversation(portal.discussiondocument) + >>> conv.enabled() + False + +This is because discussion is disabled by default for the document content +type:: + + >>> fti.allow_discussion + False + +If we allow discussion for the 'Document' content type, the conversation +for our content object is enabled because it just uses the default setting +(because allow_discussion is set to None):: + + >>> fti.allow_discussion = True + >>> from plone.app.discussion.interfaces import IConversation + >>> conv = IConversation(portal.discussiondocument) + >>> conv.enabled() + True + +We can now override the default value (True) by explicitly setting allow discussion to False:: + + >>> browser.open('http://nohost/plone/discussiondocument/edit') + >>> allowDiscussion = browser.getControl('Allow discussion') + >>> allowDiscussion.value = ['False'] + >>> browser.getControl('Save').click() + +Discussion on our content object is now not enabled:: + + >>> from plone.app.discussion.interfaces import IConversation + >>> conv = IConversation(portal.discussiondocument) + >>> conv.enabled() + False diff --git a/plone/app/discussion/tests/test_functional.py b/plone/app/discussion/tests/test_functional.py index 5a3813d7..19e8303c 100644 --- a/plone/app/discussion/tests/test_functional.py +++ b/plone/app/discussion/tests/test_functional.py @@ -16,6 +16,7 @@ "functional_test_comments.rst", "functional_test_comment_review_workflow.txt", "functional_test_behavior_discussion.rst", + "dexterity_discussion.rst", ] From 2a4b3933ba62b5248f8779d311075eae33bb4109 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Mon, 20 May 2024 21:11:07 +0200 Subject: [PATCH 11/36] fix requirements --- setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 908d235e..a8c5c7b2 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,6 @@ zip_safe=False, python_requires=">=3.10", install_requires=[ - "Products.CMFPlone", "BTrees", "Products.GenericSetup", "Products.ZCatalog", @@ -48,9 +47,11 @@ "persistent", "plone.api", "plone.app.event", - "plone.dexterity", "plone.registry", "plone.resource", + "plone.autoform", + "plone.behavior", + "plone.supermodel", "plone.uuid", "zope.annotation", "setuptools", @@ -71,6 +72,7 @@ "plone.app.contenttypes[test]", "plone.app.robotframework", "plone.app.vocabularies", + "plone.dexterity", "plone.testing", "plone.protect", "Products.MailHost", From 9ab3065e0790c7b669cf23943eaf0f0f6c68bcd5 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Wed, 22 May 2024 13:30:07 +0200 Subject: [PATCH 12/36] add uninstall --- plone/app/discussion/configure.zcml | 77 +++++++++++-------- .../discussion/profiles/uninstall/actions.xml | 13 ++++ .../profiles/uninstall/browserlayer.xml | 6 ++ .../discussion/profiles/uninstall/catalog.xml | 18 +++++ .../profiles/uninstall/controlpanel.xml | 14 ++++ .../profiles/uninstall/registry.xml | 6 ++ plone/app/discussion/setuphandlers.py | 24 +++++- 7 files changed, 122 insertions(+), 36 deletions(-) create mode 100644 plone/app/discussion/profiles/uninstall/actions.xml create mode 100644 plone/app/discussion/profiles/uninstall/browserlayer.xml create mode 100644 plone/app/discussion/profiles/uninstall/catalog.xml create mode 100644 plone/app/discussion/profiles/uninstall/controlpanel.xml create mode 100644 plone/app/discussion/profiles/uninstall/registry.xml diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index 1a2e663b..4a19dafd 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -7,50 +7,59 @@ i18n_domain="plone" > - + - - - - - + + + + + - - - - - - + + + + + + - + - + - + - + - + - - - - + + + + + - + - + - + - + - + + + + + + diff --git a/plone/app/discussion/profiles/uninstall/browserlayer.xml b/plone/app/discussion/profiles/uninstall/browserlayer.xml new file mode 100644 index 00000000..078a4cbb --- /dev/null +++ b/plone/app/discussion/profiles/uninstall/browserlayer.xml @@ -0,0 +1,6 @@ + + + + diff --git a/plone/app/discussion/profiles/uninstall/catalog.xml b/plone/app/discussion/profiles/uninstall/catalog.xml new file mode 100644 index 00000000..fe787701 --- /dev/null +++ b/plone/app/discussion/profiles/uninstall/catalog.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/plone/app/discussion/profiles/uninstall/controlpanel.xml b/plone/app/discussion/profiles/uninstall/controlpanel.xml new file mode 100644 index 00000000..2506618d --- /dev/null +++ b/plone/app/discussion/profiles/uninstall/controlpanel.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/plone/app/discussion/profiles/uninstall/registry.xml b/plone/app/discussion/profiles/uninstall/registry.xml new file mode 100644 index 00000000..234fa24d --- /dev/null +++ b/plone/app/discussion/profiles/uninstall/registry.xml @@ -0,0 +1,6 @@ + + + + diff --git a/plone/app/discussion/setuphandlers.py b/plone/app/discussion/setuphandlers.py index ed3e575d..e16eb4c6 100644 --- a/plone/app/discussion/setuphandlers.py +++ b/plone/app/discussion/setuphandlers.py @@ -12,15 +12,35 @@ "Link", ] +BEHAVIOR = "plone.allowdiscussion" + def add_discussion_behavior_to_default_types(context): """Add the discussion behavior to all default types, if they exist.""" types_tool = getToolByName(context, "portal_types") for type_name in DEFAULT_TYPES: - if type_name in types_tool.objectIds(): - types_tool[type_name].behaviors += ("plone.allowdiscussion",) + if type_name in types_tool.objectIds() and BEHAVIOR not in types_tool[type_name].behaviors: + types_tool[type_name].behaviors += (BEHAVIOR,) + + +def remove_discussion_behavior_to_default_types(context): + """Remove the discussion behavior from all default types, if they exist.""" + types_tool = getToolByName(context, "portal_types") + for type_name in types_tool.objectIds(): + fti = types_tool[type_name] + if getattr(fti, "behaviors", None) is None: + continue + if BEHAVIOR in fti.behaviors: + behaviors = list(fti.behaviors) + behaviors.remove(BEHAVIOR) + fti.behaviors = tuple(behaviors) def post_install(context): """Post install script""" add_discussion_behavior_to_default_types(context) + + +def post_uninstall(context): + """Post uninstall script""" + remove_discussion_behavior_to_default_types(context) From 7a806ba390e489307a8d1fb686905c3d15e0d498 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 11:37:31 +0000 Subject: [PATCH 13/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- plone/app/discussion/configure.zcml | 86 +++++++++---------- .../discussion/profiles/uninstall/catalog.xml | 20 +++-- plone/app/discussion/setuphandlers.py | 5 +- 3 files changed, 62 insertions(+), 49 deletions(-) diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index 4a19dafd..3eee5027 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -7,59 +7,59 @@ i18n_domain="plone" > - + - - - - - + + + + + - - - - - - + + + + + + - + - + - + - + - + - - - - - + + + + + - + - + - + - + - + - - - - - + + + + + diff --git a/plone/app/discussion/setuphandlers.py b/plone/app/discussion/setuphandlers.py index e16eb4c6..2d40dabc 100644 --- a/plone/app/discussion/setuphandlers.py +++ b/plone/app/discussion/setuphandlers.py @@ -19,7 +19,10 @@ def add_discussion_behavior_to_default_types(context): """Add the discussion behavior to all default types, if they exist.""" types_tool = getToolByName(context, "portal_types") for type_name in DEFAULT_TYPES: - if type_name in types_tool.objectIds() and BEHAVIOR not in types_tool[type_name].behaviors: + if ( + type_name in types_tool.objectIds() + and BEHAVIOR not in types_tool[type_name].behaviors + ): types_tool[type_name].behaviors += (BEHAVIOR,) From f2f16027672f5f4f939a9a2aaf0cda3f584a6d8b Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Thu, 30 May 2024 16:42:32 +0200 Subject: [PATCH 14/36] move cpanel to content section as this is not core any more --- plone/app/discussion/profiles/default/controlpanel.xml | 2 +- plone/app/discussion/profiles/uninstall/controlpanel.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plone/app/discussion/profiles/default/controlpanel.xml b/plone/app/discussion/profiles/default/controlpanel.xml index d85f7a47..d98078ea 100644 --- a/plone/app/discussion/profiles/default/controlpanel.xml +++ b/plone/app/discussion/profiles/default/controlpanel.xml @@ -7,7 +7,7 @@ From 8217f261332695e7a2544f0ce4cef885161c489e Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Thu, 30 May 2024 17:50:35 +0200 Subject: [PATCH 15/36] README overhaul --- README.rst | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/README.rst b/README.rst index 3753d940..9e9f4bba 100644 --- a/README.rst +++ b/README.rst @@ -1,18 +1,22 @@ Introduction ============ +plone.app.discussion is the commenting add-on for Plone. +It is part of the maintained Plone core. -plone.app.discussion is the commenting system used since Plone 4.1. -It was initially developed as part of the Google Summer of Code 2009 by Timo Stollenwerk (student) and Martin Aspeli (mentor). +Installation +============ +If your installation depends on the `Plone `_ package, you can install it via the Plone control panel. +In case you do only depend on either the `plone.volto`, `plone.classicui` or `Products.CMFPlone` package, you need to add it to your requirements file. +After adding it and installing the requirement, you can install it via the Plone control panel. -Add-on Products +Spam protection =============== -- `collective.autoresizetextarea - `_ - (for auto-resizing the comment textarea while typing) +These days it is essential to protect your site from commenting spam. +The following add-ons can help to protect your site: - `plone.formwidget.captcha `_ @@ -22,33 +26,24 @@ Add-on Products `_ (for ReCaptcha spam protection) -- `collective.akismet - `_ - (for Akismet spam protection) - - `collective.z3cform.norobots - `_ + `_ (provides a "human" captcha widget based on a list of questions/answers) - `plone.formwidget.hcaptcha `_ (for spam protection by `HCaptcha `_ ) -Note: not all of these may be compatible with the current version of ``plone.app.discussion`` and ``Plone`` itself. - Documentation ============= -There is initial `documentation `_ but it is outdated. -You will still get a feel for how the package is structured though. - +For further information, please refer to the `official Plone documentation `_. Credits ======= -- Timo Stollenwerk -- Martin Aspeli +This pakcage was initially developed as part of the Google Summer of Code 2009 by Timo Stollenwerk (student) and Martin Aspeli (mentor). Many thanks to: @@ -59,4 +54,4 @@ Many thanks to: - Hanno Schlichting (for making p.a.d work with Zope 2.12) - Alan Hoey (for providing fixes) - Maik Roeder (for providing and setting up a buildbot) - +- Jens Klein (for ripping it out of core and making it a separate core-addon for Plone 6.1) From e416b703e74149c3d775a12352e7b586397fd142 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Fri, 31 May 2024 00:13:39 +0200 Subject: [PATCH 16/36] typo --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9e9f4bba..caf71abd 100644 --- a/README.rst +++ b/README.rst @@ -43,7 +43,7 @@ For further information, please refer to the `official Plone documentation Date: Fri, 31 May 2024 18:34:40 +0200 Subject: [PATCH 17/36] move test from CMFPlone here --- .../tests/robot/test_allow_discussion.robot | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 plone/app/discussion/tests/robot/test_allow_discussion.robot diff --git a/plone/app/discussion/tests/robot/test_allow_discussion.robot b/plone/app/discussion/tests/robot/test_allow_discussion.robot new file mode 100644 index 00000000..e40530a1 --- /dev/null +++ b/plone/app/discussion/tests/robot/test_allow_discussion.robot @@ -0,0 +1,68 @@ +*** Settings ***************************************************************** + +Resource plone/app/robotframework/keywords.robot +Resource plone/app/robotframework/saucelabs.robot +Resource plone/app/robotframework/selenium.robot + +Library Remote ${PLONE_URL}/RobotRemote + +Resource keywords.robot + +Test Setup Run keywords Plone Test Setup +Test Teardown Run keywords Plone Test Teardown + + +*** Test Cases *************************************************************** + +Scenario: Allow comments for Link Type + Given a logged-in manager + and Globally enabled comments + and the types control panel + When I select 'Link' in types dropdown + and Allow discussion + Then Wait until page contains Content Settings + When I add new Link 'my_link' + Then Link 'my_link' should have comments enabled + + +*** Keywords ***************************************************************** + +# --- GIVEN ------------------------------------------------------------------ + +a logged-in manager + Enable autologin as Manager + +the types control panel + Go to ${PLONE_URL}/@@content-controlpanel + Wait until page contains Content Settings + +Globally enabled comments + Go to ${PLONE_URL}/@@discussion-settings + Wait until page contains Discussion settings + Select checkbox name=form.widgets.globally_enabled:list + Click button Save + + + +# --- WHEN ------------------------------------------------------------------- + +I select '${content_type}' in types dropdown + Select from list by label name=type_id ${content_type} + Wait until page contains Globally addable + +Allow discussion + Select checkbox name=allow_discussion:boolean + Click Button Save + +I add new Link '${id}' + Go to ${PLONE_URL} + Wait until page contains Plone site + Create content type=Link id=${id} title=${id} remoteUrl=http://www.starzel.de + + +# --- THEN ------------------------------------------------------------------- + +Link '${id}' should have comments enabled + Go to ${PLONE_URL}/${id} + Wait until page contains ${id} + Page should contain element xpath=//div[@id="commenting"] From 99811456f70546d068ac149195ad17975ecec707 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Fri, 31 May 2024 18:58:33 +0200 Subject: [PATCH 18/36] Fix redirection after comment edit to main content, preventing NotFound. --- news/211.bugfix | 1 + plone/app/discussion/browser/comment.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 news/211.bugfix diff --git a/news/211.bugfix b/news/211.bugfix new file mode 100644 index 00000000..43a08fec --- /dev/null +++ b/news/211.bugfix @@ -0,0 +1 @@ +Fix redirection after comment edit to main content, preventing NotFound. [@jensens] \ No newline at end of file diff --git a/plone/app/discussion/browser/comment.py b/plone/app/discussion/browser/comment.py index d11dfeb4..e52f86ae 100644 --- a/plone/app/discussion/browser/comment.py +++ b/plone/app/discussion/browser/comment.py @@ -104,7 +104,8 @@ def handle_cancel(self, action): _("comment_edit_cancel_notification", default="Edit comment cancelled"), type="info", ) - return self._redirect(target=self.context.absolute_url()) + main_content = aq_parent(aq_parent(self.context)) + return self._redirect(target=main_content.absolute_url()) EditComment = wrap_form(EditCommentForm) From a6d7a4df1794bfb973bb16a05fd1cf18d9cee451 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:45:02 +0000 Subject: [PATCH 19/36] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.15.2 → v3.16.0](https://github.com/asottile/pyupgrade/compare/v3.15.2...v3.16.0) - [github.com/PyCQA/flake8: 7.0.0 → 7.1.0](https://github.com/PyCQA/flake8/compare/7.0.0...7.1.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da56023f..3479cc26 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ ci: repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + rev: v3.16.0 hooks: - id: pyupgrade args: [--py38-plus] @@ -32,7 +32,7 @@ repos: # """ ## - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 + rev: 7.1.0 hooks: - id: flake8 From c8e7340b5b01995bc3f9a1f468c3d05286834a47 Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Wed, 3 May 2023 09:26:46 +0200 Subject: [PATCH 20/36] Test drop five:registerPackage Is that actually needed in Plone 6? --- plone/app/discussion/configure.zcml | 2 -- 1 file changed, 2 deletions(-) diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index 3eee5027..76c04e9a 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -7,8 +7,6 @@ i18n_domain="plone" > - - From ae39d5968af9d24c6ed9f7d4cca0e67d11d584e0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:33:09 +0000 Subject: [PATCH 21/36] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.16.0 → v3.17.0](https://github.com/asottile/pyupgrade/compare/v3.16.0...v3.17.0) - [github.com/psf/black: 24.4.2 → 24.8.0](https://github.com/psf/black/compare/24.4.2...24.8.0) - [github.com/PyCQA/flake8: 7.1.0 → 7.1.1](https://github.com/PyCQA/flake8/compare/7.1.0...7.1.1) - [github.com/collective/i18ndude: 6.2.0 → 6.2.1](https://github.com/collective/i18ndude/compare/6.2.0...6.2.1) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3479cc26..14603265 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ ci: repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.16.0 + rev: v3.17.0 hooks: - id: pyupgrade args: [--py38-plus] @@ -16,7 +16,7 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black - repo: https://github.com/collective/zpretty @@ -32,7 +32,7 @@ repos: # """ ## - repo: https://github.com/PyCQA/flake8 - rev: 7.1.0 + rev: 7.1.1 hooks: - id: flake8 @@ -71,7 +71,7 @@ repos: - id: check-python-versions args: ['--only', 'setup.py,pyproject.toml'] - repo: https://github.com/collective/i18ndude - rev: "6.2.0" + rev: "6.2.1" hooks: - id: i18ndude From e66c836f6d2edd8434227910d1bb81a2ae9b0e01 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Tue, 13 Aug 2024 18:24:52 +0200 Subject: [PATCH 22/36] Uninstall profile: remove Discussion Item from portal_types tool. --- plone/app/discussion/profiles/uninstall/types.xml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plone/app/discussion/profiles/uninstall/types.xml diff --git a/plone/app/discussion/profiles/uninstall/types.xml b/plone/app/discussion/profiles/uninstall/types.xml new file mode 100644 index 00000000..86b5306b --- /dev/null +++ b/plone/app/discussion/profiles/uninstall/types.xml @@ -0,0 +1,9 @@ + + + + From f9c646990d88e37d864d9bc0bf2d8004fe595c8c Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Tue, 13 Aug 2024 18:27:31 +0200 Subject: [PATCH 23/36] Uninstall profile: remove our workflow definitions. --- .../app/discussion/profiles/uninstall/workflows.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 plone/app/discussion/profiles/uninstall/workflows.xml diff --git a/plone/app/discussion/profiles/uninstall/workflows.xml b/plone/app/discussion/profiles/uninstall/workflows.xml new file mode 100644 index 00000000..b7269a77 --- /dev/null +++ b/plone/app/discussion/profiles/uninstall/workflows.xml @@ -0,0 +1,13 @@ + + + + + From f896cb4d5da9a128822ccbd317763c56f97bf1db Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Tue, 13 Aug 2024 19:32:16 +0200 Subject: [PATCH 24/36] Configuring with plone/meta --- .meta.toml | 5 ++++- tox.ini | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.meta.toml b/.meta.toml index abdbeba6..3d682dc3 100644 --- a/.meta.toml +++ b/.meta.toml @@ -3,7 +3,10 @@ # See the inline comments on how to expand/tweak this configuration file [meta] template = "default" -commit-id = "a89af8f2" +commit-id = "7a017355" [pyproject] dependencies_ignores = "['Products.LinguaPlone.interfaces.ITranslatable', 'collective.akismet', 'collective.z3cform.norobots', 'plone.formwidget.captcha', 'plone.formwidget.recaptcha', 'plone.formwidget.hcaptcha', 'plone.contentrules', 'plone.app.contentrules', 'plone.stringinterp', 'plone.app.collection']" + +[tox] +constraints_file = "https://dist.plone.org/release/6.1-dev/constraints.txt" diff --git a/tox.ini b/tox.ini index c6869f58..a44a828d 100644 --- a/tox.ini +++ b/tox.ini @@ -108,7 +108,7 @@ set_env = ## deps = zope.testrunner - -c https://dist.plone.org/release/6.0-dev/constraints.txt + -c https://dist.plone.org/release/6.1-dev/constraints.txt ## # Specify additional deps in .meta.toml: @@ -152,7 +152,7 @@ set_env = deps = coverage zope.testrunner - -c https://dist.plone.org/release/6.0-dev/constraints.txt + -c https://dist.plone.org/release/6.1-dev/constraints.txt commands = rfbrowser init @@ -171,7 +171,7 @@ deps = twine build towncrier - -c https://dist.plone.org/release/6.0-dev/constraints.txt + -c https://dist.plone.org/release/6.1-dev/constraints.txt commands = # fake version to not have to install the package @@ -202,7 +202,7 @@ allowlist_externals = deps = pipdeptree pipforester - -c https://dist.plone.org/release/6.0-dev/constraints.txt + -c https://dist.plone.org/release/6.1-dev/constraints.txt commands = # Generate the full dependency tree From 603c903eb8995711014ab8cebd56305a5fc1d949 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Tue, 13 Aug 2024 21:46:27 +0200 Subject: [PATCH 25/36] Robot tests: install our GS profile. I noticed that on Jenkins only 142 robot tests were run instead of 149. The console showed the reason: ``` Set up plone.app.contenttypes.testing.PloneAppContenttypes in 0.020 seconds. Set up plone.app.robotframework.testing.SimplePublicationLayer in 0.001 seconds. Set up plone.app.robotframework.remote.RemoteLibraryBundle:RobotRemote in 0.000 seconds. Set up plone.testing.zope.WSGIServer in 0.043 seconds. Set up plone.app.robotframework.testing.RemoteLibrary:Robot in 0.000 seconds. Set up plone.app.discussion.testing.PloneAppDiscussionRobot Traceback (most recent call last): File "/Users/maurits/shared-eggs/cp311/zope.testrunner-6.4-py3.11.egg/zope/testrunner/runner.py", line 474, in run_layer setup_layer(options, layer, setup_layers) File "/Users/maurits/shared-eggs/cp311/zope.testrunner-6.4-py3.11.egg/zope/testrunner/runner.py", line 839, in setup_layer setup_layer(options, base, setup_layers) File "/Users/maurits/shared-eggs/cp311/zope.testrunner-6.4-py3.11.egg/zope/testrunner/runner.py", line 844, in setup_layer layer.setUp() File "/Users/maurits/shared-eggs/cp311/plone.app.testing-7.1.0-py3.11.egg/plone/app/testing/helpers.py", line 378, in setUp self.setUpPloneSite(portal) File "/Users/maurits/community/plone-coredev/6.1/src/plone.app.discussion/plone/app/discussion/testing.py", line 111, in setUpPloneSite settings = registry.forInterface(IDiscussionSettings) File "/Users/maurits/shared-eggs/cp311/plone.registry-2.0.1-py3.11.egg/plone/registry/registry.py", line 71, in forInterface raise KeyError( KeyError: 'Interface `plone.app.discussion.interfaces.IDiscussionSettings` defines a field `globally_enabled`, for which there is no record.' ``` --- plone/app/discussion/testing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plone/app/discussion/testing.py b/plone/app/discussion/testing.py index fe23d84f..48a74392 100644 --- a/plone/app/discussion/testing.py +++ b/plone/app/discussion/testing.py @@ -106,6 +106,7 @@ class PloneAppDiscussionRobot(PloneAppDiscussion): ) def setUpPloneSite(self, portal): + applyProfile(portal, "plone.app.discussion:default") registry = queryUtility(IRegistry) settings = registry.forInterface(IDiscussionSettings) settings.globally_enabled = True From 5ed24388745819de2d1f3f6e8b71462e4608b71a Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Tue, 13 Aug 2024 21:48:23 +0200 Subject: [PATCH 26/36] Robot tests: we have no own keywords.robot file. We are already loading a file with the same name from plone.app.robotframework. --- plone/app/discussion/tests/robot/test_allow_discussion.robot | 2 -- 1 file changed, 2 deletions(-) diff --git a/plone/app/discussion/tests/robot/test_allow_discussion.robot b/plone/app/discussion/tests/robot/test_allow_discussion.robot index e40530a1..d2ed6117 100644 --- a/plone/app/discussion/tests/robot/test_allow_discussion.robot +++ b/plone/app/discussion/tests/robot/test_allow_discussion.robot @@ -6,8 +6,6 @@ Resource plone/app/robotframework/selenium.robot Library Remote ${PLONE_URL}/RobotRemote -Resource keywords.robot - Test Setup Run keywords Plone Test Setup Test Teardown Run keywords Plone Test Teardown From 121a2565f83fad1f874dcfc82a728076e95fefa6 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Mon, 19 Aug 2024 14:41:18 +0200 Subject: [PATCH 27/36] Removed tests/dexterity_discussion.rst This was moved here from `plone.app.dexterity`, but it has the exact same contents as `tests/functional_test_behavior_discussion.rst`. I compared again with the original in `plone.app.dexterity`, and it is indeed the same, except that the behavior name is fixed to `plone.allowdiscussion` instead of the former `plone.app.dexterity.behaviors.discussion.IAllowDiscussion`. --- .../discussion/tests/dexterity_discussion.rst | 106 ------------------ 1 file changed, 106 deletions(-) delete mode 100644 plone/app/discussion/tests/dexterity_discussion.rst diff --git a/plone/app/discussion/tests/dexterity_discussion.rst b/plone/app/discussion/tests/dexterity_discussion.rst deleted file mode 100644 index f86925b4..00000000 --- a/plone/app/discussion/tests/dexterity_discussion.rst +++ /dev/null @@ -1,106 +0,0 @@ -Allow Discussion -================ - -Test Setup ----------- - -We create a dexterity content type that provides the allow discussion behavior:: - - >>> portal = layer['portal'] - >>> from plone.dexterity.fti import DexterityFTI - >>> fti = DexterityFTI('discussiondocument') - >>> fti.behaviors = ('plone.allowdiscussion',) - >>> portal.portal_types._setObject('discussiondocument', fti) - 'discussiondocument' - -Set up a test browser:: - - >>> from plone.app.testing import TEST_USER_ID, TEST_USER_NAME, TEST_USER_PASSWORD, setRoles - >>> setRoles(portal, TEST_USER_ID, ['Manager']) - >>> import transaction; transaction.commit() - >>> from plone.testing.zope import Browser - >>> browser = Browser(layer['app']) - >>> browser.addHeader('Authorization', 'Basic %s:%s' % (TEST_USER_NAME, TEST_USER_PASSWORD,)) - -We have to make sure the request provides IDiscussonLayer because the enabled -method on the conversation calls conversation_view (which is only registered -for IDiscussionLayer). - - >>> from plone.app.discussion.interfaces import IDiscussionLayer - >>> from zope.interface import alsoProvides - >>> alsoProvides(portal.REQUEST, IDiscussionLayer) - -Add a document:: - - >>> browser.open('http://nohost/plone/++add++discussiondocument') - - -Default Allow Discussion Options --------------------------------- - -There are three options for the allow discussion select field:: - - >>> allowDiscussion = browser.getControl('Allow discussion') - >>> allowDiscussion.options - ['--NOVALUE--', 'True', 'False'] - -By default, no value is set for allow discussion:: - - >>> browser.getControl('Allow discussion').value - ['--NOVALUE--'] - >>> browser.getControl('Save').click() - >>> browser.url - 'http://nohost/plone/discussiondocument/view' - -This means discussion is not enabled: - - >>> from plone.app.discussion.interfaces import IConversation - >>> conv = IConversation(portal.discussiondocument) - >>> conv.enabled() - False - -We have to globally enable discussion in order to be able to add comments:: - - >>> from plone.registry.interfaces import IRegistry - >>> from zope.component import queryUtility - >>> from plone.app.discussion.interfaces import IDiscussionSettings - >>> registry = queryUtility(IRegistry) - >>> settings = registry.forInterface(IDiscussionSettings) - >>> settings.globally_enabled = True - -Discussion is still disabled for our content object though:: - - >>> from plone.app.discussion.interfaces import IConversation - >>> conv = IConversation(portal.discussiondocument) - >>> conv.enabled() - False - -This is because discussion is disabled by default for the document content -type:: - - >>> fti.allow_discussion - False - -If we allow discussion for the 'Document' content type, the conversation -for our content object is enabled because it just uses the default setting -(because allow_discussion is set to None):: - - >>> fti.allow_discussion = True - >>> from plone.app.discussion.interfaces import IConversation - >>> conv = IConversation(portal.discussiondocument) - >>> conv.enabled() - True - -We can now override the default value (True) by explicitly setting allow discussion to False:: - - >>> browser.open('http://nohost/plone/discussiondocument/edit') - >>> allowDiscussion = browser.getControl('Allow discussion') - >>> allowDiscussion.value = ['False'] - >>> browser.getControl('Save').click() - -Discussion on our content object is now not enabled:: - - >>> from plone.app.discussion.interfaces import IConversation - >>> conv = IConversation(portal.discussiondocument) - >>> conv.enabled() - False From da5b2f5f8770eb3683974e9a0db0ab79e56933b3 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Mon, 19 Aug 2024 14:53:59 +0200 Subject: [PATCH 28/36] Remove unused content_icon and content_meta_type properties from FTI. The FTIs in `plone.app.contenttypes` do not have them. --- plone/app/discussion/profiles/default/types/Discussion_Item.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/plone/app/discussion/profiles/default/types/Discussion_Item.xml b/plone/app/discussion/profiles/default/types/Discussion_Item.xml index 31be160f..2c3a8f53 100644 --- a/plone/app/discussion/profiles/default/types/Discussion_Item.xml +++ b/plone/app/discussion/profiles/default/types/Discussion_Item.xml @@ -11,8 +11,6 @@ i18n:translate="" >Discussion Items are documents which reply to other content. They should *not* be addable through the standard 'folder_factories' interface. - string:${portal_url}/discussionitem_icon.png - Discussion Item plone.Comment From a8f000dfb2fa29bf7346d3dc3029e977486ecc12 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Mon, 19 Aug 2024 15:26:46 +0200 Subject: [PATCH 29/36] FTI: use @@view alias instead non-existing discussionitem_view. --- .../app/discussion/profiles/default/types/Discussion_Item.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plone/app/discussion/profiles/default/types/Discussion_Item.xml b/plone/app/discussion/profiles/default/types/Discussion_Item.xml index 2c3a8f53..13f1b91e 100644 --- a/plone/app/discussion/profiles/default/types/Discussion_Item.xml +++ b/plone/app/discussion/profiles/default/types/Discussion_Item.xml @@ -19,10 +19,10 @@ False Date: Mon, 19 Aug 2024 16:01:24 +0200 Subject: [PATCH 30/36] Revert "Remove unused content_icon and content_meta_type properties from FTI." This reverts commit da5b2f5f8770eb3683974e9a0db0ab79e56933b3. I looked at `plone.app.contenttypes` for comparison, but those are Dexterity FTIs, and here we have an old-style FTI. When I locally added `icon_expr` in here, I actually got an error while adding a Plone Site: ``` ValueError: http://localhost:8080/@@plone-addsite Traceback (innermost last): Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents Module ZPublisher.WSGIPublisher, line 391, in publish_module Module ZPublisher.WSGIPublisher, line 285, in publish Module ZPublisher.mapply, line 98, in mapply Module ZPublisher.WSGIPublisher, line 68, in call_object Module Products.CMFPlone.browser.admin, line 299, in __call__ Module Products.CMFPlone.factory, line 165, in addPloneSite Module Products.GenericSetup.tool, line 393, in runAllImportStepsFromProfile - __traceback_info__: profile-Products.CMFPlone:plone Module Products.GenericSetup.tool, line 1513, in _runImportStepsFromContext Module Products.GenericSetup.tool, line 1360, in _doRunHandler Module Products.CMFPlone.setuphandlers, line 139, in importFinalSteps Module Products.GenericSetup.tool, line 393, in runAllImportStepsFromProfile - __traceback_info__: profile-Products.CMFPlone:dependencies Module Products.GenericSetup.tool, line 1504, in _runImportStepsFromContext Module Products.GenericSetup.tool, line 1316, in _doRunImportStep - __traceback_info__: typeinfo Module Products.CMFCore.exportimport.typeinfo, line 222, in importTypesTool Module Products.GenericSetup.utils, line 926, in importObjects - __traceback_info__: portal_types Module Products.GenericSetup.utils, line 922, in importObjects - __traceback_info__: types/Discussion_Item Module Products.GenericSetup.utils, line 525, in _importBody Module Products.CMFCore.exportimport.typeinfo, line 61, in _importNode Module Products.GenericSetup.utils, line 757, in _initProperties ValueError: undefined property 'content_icon' ``` So let's keep the old-style properties, although I am not sure they are actually used anywhere in current Plone. --- plone/app/discussion/profiles/default/types/Discussion_Item.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plone/app/discussion/profiles/default/types/Discussion_Item.xml b/plone/app/discussion/profiles/default/types/Discussion_Item.xml index 13f1b91e..4598e375 100644 --- a/plone/app/discussion/profiles/default/types/Discussion_Item.xml +++ b/plone/app/discussion/profiles/default/types/Discussion_Item.xml @@ -11,6 +11,8 @@ i18n:translate="" >Discussion Items are documents which reply to other content. They should *not* be addable through the standard 'folder_factories' interface. + string:${portal_url}/discussionitem_icon.png + Discussion Item plone.Comment From 473224a5b15f0f157d7971fe6c65fc11359f8caf Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Tue, 6 Feb 2024 12:49:19 +0100 Subject: [PATCH 31/36] Add missing icon The `view` action of comments had no icon on Plone 6. --- .../app/discussion/profiles/default/types/Discussion_Item.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plone/app/discussion/profiles/default/types/Discussion_Item.xml b/plone/app/discussion/profiles/default/types/Discussion_Item.xml index 4598e375..ad1d4b3c 100644 --- a/plone/app/discussion/profiles/default/types/Discussion_Item.xml +++ b/plone/app/discussion/profiles/default/types/Discussion_Item.xml @@ -30,7 +30,8 @@ category="object" condition_expr="" title="View" - url_expr="string:${object_url}/discussionitem_view" + url_expr="string:${object_url}/@@view" + icon_expr="string:toolbar-action/view" visible="True" i18n:attributes="title" > From 840a4457bbff1aea905ca36217adb1e381582833 Mon Sep 17 00:00:00 2001 From: Gil Forcada Codinachs Date: Tue, 6 Feb 2024 12:50:13 +0100 Subject: [PATCH 32/36] Add news entry --- news/+ignore.bugfix | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 news/+ignore.bugfix diff --git a/news/+ignore.bugfix b/news/+ignore.bugfix new file mode 100644 index 00000000..7f7f4e85 --- /dev/null +++ b/news/+ignore.bugfix @@ -0,0 +1,2 @@ +Add missing icon on comments' `view` action +[gforcada] From ebd965ccd57fbef3cf914f07245e6fada695bf2a Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Mon, 19 Aug 2024 15:50:15 +0200 Subject: [PATCH 33/36] Register contenttype icon. Add upgrade step for updating the icons. Update the profile version to 3000. This leaves room for upgrades on the 4.x branch (Plone 6.0). --- news/+ignore.bugfix | 2 -- news/222.bugfix | 3 +++ plone/app/discussion/configure.zcml | 5 ++++ .../discussion/profiles/default/metadata.xml | 2 +- .../discussion/profiles/default/registry.xml | 6 +++++ .../default/types/Discussion_Item.xml | 4 +-- .../discussion/profiles/to_2002/registry.xml | 9 +++++++ .../to_2002/types/Discussion_Item.xml | 26 +++++++++++++++++++ plone/app/discussion/setuphandlers.py | 10 +++++++ plone/app/discussion/upgrades.zcml | 14 +++++++++- 10 files changed, 75 insertions(+), 6 deletions(-) delete mode 100644 news/+ignore.bugfix create mode 100644 news/222.bugfix create mode 100644 plone/app/discussion/profiles/to_2002/registry.xml create mode 100644 plone/app/discussion/profiles/to_2002/types/Discussion_Item.xml diff --git a/news/+ignore.bugfix b/news/+ignore.bugfix deleted file mode 100644 index 7f7f4e85..00000000 --- a/news/+ignore.bugfix +++ /dev/null @@ -1,2 +0,0 @@ -Add missing icon on comments' `view` action -[gforcada] diff --git a/news/222.bugfix b/news/222.bugfix new file mode 100644 index 00000000..6f0a228f --- /dev/null +++ b/news/222.bugfix @@ -0,0 +1,3 @@ +Add missing icon on comments' `view` action +Register contenttype icon for comments. +[gforcada, maurits] diff --git a/plone/app/discussion/configure.zcml b/plone/app/discussion/configure.zcml index 76c04e9a..2653af7a 100644 --- a/plone/app/discussion/configure.zcml +++ b/plone/app/discussion/configure.zcml @@ -55,6 +55,11 @@ directory="profiles/uninstall" post_handler=".setuphandlers.post_uninstall" /> + diff --git a/plone/app/discussion/profiles/default/metadata.xml b/plone/app/discussion/profiles/default/metadata.xml index 4cad4f61..15f3d34a 100644 --- a/plone/app/discussion/profiles/default/metadata.xml +++ b/plone/app/discussion/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 2002 + 3000 profile-plone.resource:default profile-plone.app.registry:default diff --git a/plone/app/discussion/profiles/default/registry.xml b/plone/app/discussion/profiles/default/registry.xml index 2a1aaffc..944359d3 100644 --- a/plone/app/discussion/profiles/default/registry.xml +++ b/plone/app/discussion/profiles/default/registry.xml @@ -4,4 +4,10 @@ False False + + + Plone Image + + ++plone++bootstrap-icons/chat-left-text.svg + diff --git a/plone/app/discussion/profiles/default/types/Discussion_Item.xml b/plone/app/discussion/profiles/default/types/Discussion_Item.xml index ad1d4b3c..fb1cc595 100644 --- a/plone/app/discussion/profiles/default/types/Discussion_Item.xml +++ b/plone/app/discussion/profiles/default/types/Discussion_Item.xml @@ -11,7 +11,7 @@ i18n:translate="" >Discussion Items are documents which reply to other content. They should *not* be addable through the standard 'folder_factories' interface. - string:${portal_url}/discussionitem_icon.png + ++plone++bootstrap-icons/chat-left-text.svg Discussion Item plone.Comment @@ -29,9 +29,9 @@ diff --git a/plone/app/discussion/profiles/to_2002/registry.xml b/plone/app/discussion/profiles/to_2002/registry.xml new file mode 100644 index 00000000..e7886adb --- /dev/null +++ b/plone/app/discussion/profiles/to_2002/registry.xml @@ -0,0 +1,9 @@ + + + + + Plone Image + + ++plone++bootstrap-icons/chat-left-text.svg + + diff --git a/plone/app/discussion/profiles/to_2002/types/Discussion_Item.xml b/plone/app/discussion/profiles/to_2002/types/Discussion_Item.xml new file mode 100644 index 00000000..92fb9496 --- /dev/null +++ b/plone/app/discussion/profiles/to_2002/types/Discussion_Item.xml @@ -0,0 +1,26 @@ + + + ++plone++bootstrap-icons/chat-left-text.svg + + + + + + + diff --git a/plone/app/discussion/setuphandlers.py b/plone/app/discussion/setuphandlers.py index 2d40dabc..58215a3a 100644 --- a/plone/app/discussion/setuphandlers.py +++ b/plone/app/discussion/setuphandlers.py @@ -1,4 +1,6 @@ +from plone.base.interfaces import INonInstallable from Products.CMFCore.utils import getToolByName +from zope.interface import implementer DEFAULT_TYPES = [ @@ -15,6 +17,14 @@ BEHAVIOR = "plone.allowdiscussion" +@implementer(INonInstallable) +class HiddenProfiles: + def getNonInstallableProfiles(self): + return [ + "plone.app.contenttypes:to_3000", + ] + + def add_discussion_behavior_to_default_types(context): """Add the discussion behavior to all default types, if they exist.""" types_tool = getToolByName(context, "portal_types") diff --git a/plone/app/discussion/upgrades.zcml b/plone/app/discussion/upgrades.zcml index e63f85d6..129b73ee 100644 --- a/plone/app/discussion/upgrades.zcml +++ b/plone/app/discussion/upgrades.zcml @@ -108,11 +108,23 @@ /> + + + Date: Tue, 20 Aug 2024 10:22:19 +0200 Subject: [PATCH 34/36] Removed reference to unneeded test file that I removed yesterday. --- plone/app/discussion/tests/test_functional.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plone/app/discussion/tests/test_functional.py b/plone/app/discussion/tests/test_functional.py index 19e8303c..5a3813d7 100644 --- a/plone/app/discussion/tests/test_functional.py +++ b/plone/app/discussion/tests/test_functional.py @@ -16,7 +16,6 @@ "functional_test_comments.rst", "functional_test_comment_review_workflow.txt", "functional_test_behavior_discussion.rst", - "dexterity_discussion.rst", ] From 7e32976c6d0e9c6b1c9c02d5a0bd6df0aff01fef Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Tue, 20 Aug 2024 10:23:16 +0200 Subject: [PATCH 35/36] Fix hidden profile id. --- plone/app/discussion/setuphandlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plone/app/discussion/setuphandlers.py b/plone/app/discussion/setuphandlers.py index 58215a3a..19afede9 100644 --- a/plone/app/discussion/setuphandlers.py +++ b/plone/app/discussion/setuphandlers.py @@ -21,7 +21,7 @@ class HiddenProfiles: def getNonInstallableProfiles(self): return [ - "plone.app.contenttypes:to_3000", + "plone.app.discussion:to_3000", ] From 98aee4a30a5988f850b85a86a1fe9855b179b00d Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Tue, 20 Aug 2024 10:23:56 +0200 Subject: [PATCH 36/36] Rename profiles/to_2002 to profiles/to_3000. --- plone/app/discussion/profiles/{to_2002 => to_3000}/registry.xml | 0 .../profiles/{to_2002 => to_3000}/types/Discussion_Item.xml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename plone/app/discussion/profiles/{to_2002 => to_3000}/registry.xml (100%) rename plone/app/discussion/profiles/{to_2002 => to_3000}/types/Discussion_Item.xml (100%) diff --git a/plone/app/discussion/profiles/to_2002/registry.xml b/plone/app/discussion/profiles/to_3000/registry.xml similarity index 100% rename from plone/app/discussion/profiles/to_2002/registry.xml rename to plone/app/discussion/profiles/to_3000/registry.xml diff --git a/plone/app/discussion/profiles/to_2002/types/Discussion_Item.xml b/plone/app/discussion/profiles/to_3000/types/Discussion_Item.xml similarity index 100% rename from plone/app/discussion/profiles/to_2002/types/Discussion_Item.xml rename to plone/app/discussion/profiles/to_3000/types/Discussion_Item.xml