Skip to content

Commit

Permalink
Merge branch 'main' into teaser-dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens authored Jun 4, 2024
2 parents cd3a0ee + c7b8e07 commit 681e642
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 24 deletions.
7 changes: 6 additions & 1 deletion docs/source/endpoints/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ myst:

# Comments

Plone offers to users a feature to post comments on any content object with `plone.app.discussion`.
```{versionchanged} Plone 6.1
Discussion is disabled by default in Plone 6.1 and later.
To enable discussion, see the Plone 6.1 upgrade guide section {ref}`backend-upgrade-plone-v61-discussion-label`.
```

Discussion is a feature that allows your site visitors to comment on web pages for any content object.

Commenting can be enabled globally for specific content types and for single content objects.

Expand Down
1 change: 1 addition & 0 deletions news/1781.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make plone.app.discussion an optional dependency (core add-on) [@jensens]
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def read(filename):
"plone.app.caching",
"plone.app.contenttypes[test]",
"plone.app.iterate",
"plone.app.discussion[test]",
"plone.app.testing",
"plone.app.upgrade",
"plone.api",
Expand Down
6 changes: 4 additions & 2 deletions src/plone/restapi/serializer/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@

<adapter factory=".registry.SerializeRegistryToJson" />

<adapter factory=".discussion.ConversationSerializer" />
<adapter factory=".discussion.CommentSerializer" />
<configure zcml:condition="installed plone.app.discussion">
<adapter factory=".discussion.ConversationSerializer" />
<adapter factory=".discussion.CommentSerializer" />
</configure>

<include package=".controlpanels" />

Expand Down
5 changes: 4 additions & 1 deletion src/plone/restapi/services/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
<include package=".controlpanels" />
<include package=".copymove" />
<include package=".database" />
<include package=".discussion" />
<include
package=".discussion"
zcml:condition="installed plone.app.discussion"
/>
<include package=".groups" />
<include package=".navigation" />
<include package=".contextnavigation" />
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def setUpPloneSite(self, portal):

set_supported_languages(portal)

if portal.portal_setup.profileExists("plone.app.discussion:default"):
applyProfile(portal, "plone.app.discussion:default")

applyProfile(portal, "plone.restapi:default")
applyProfile(portal, "plone.restapi:testing")
add_catalog_indexes(portal, DX_TYPES_INDEXES)
Expand Down
39 changes: 23 additions & 16 deletions src/plone/restapi/tests/statictime.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from datetime import datetime
from datetime import timezone
from DateTime import DateTime
from plone.app.discussion.comment import Comment
from plone.app.layout.viewlets.content import ContentHistoryViewlet
from plone.dexterity.content import DexterityContent
from plone.locking.lockable import TTWLockable
from plone.restapi.serializer.working_copy import WorkingCopyInfo
from Products.CMFCore.WorkflowTool import _marker
from Products.CMFCore.WorkflowTool import WorkflowTool

try:
from plone.app.discussion.comment import Comment
except ImportError:
Comment = None


_originals = {
"WorkflowTool.getInfoFor": WorkflowTool.getInfoFor,
Expand Down Expand Up @@ -106,19 +110,21 @@ def start(self):
DexterityContent.modification_date = property(
static_modification_date_getter_factory(self.static_modified), nop_setter
)

# Patch the lightweight p.a.discussion 'Comment' type. Its dates are
# Python datetimes, unlike DX Content types which use zope DateTimes.
Comment.creation_date = property(
static_creation_date_getter_factory(self.static_created, type_=datetime),
nop_setter,
)
Comment.modification_date = property(
static_modification_date_getter_factory(
self.static_modified, type_=datetime
),
nop_setter,
)
if Comment is not None:
# Patch the lightweight p.a.discussion 'Comment' type. Its dates are
# Python datetimes, unlike DX Content types which use zope DateTimes.
Comment.creation_date = property(
static_creation_date_getter_factory(
self.static_created, type_=datetime
),
nop_setter,
)
Comment.modification_date = property(
static_modification_date_getter_factory(
self.static_modified, type_=datetime
),
nop_setter,
)

WorkflowTool.getInfoFor = static_get_info_for_factory(self.static_modified)

Expand All @@ -138,8 +144,9 @@ def stop(self):
]
WorkflowTool.getInfoFor = _originals["WorkflowTool.getInfoFor"]

Comment.modification_date = None
Comment.creation_date = None
if Comment is not None:
Comment.modification_date = None
Comment.creation_date = None

WorkingCopyInfo.created = _originals["WorkingCopyInfo.created"]

Expand Down
4 changes: 0 additions & 4 deletions src/plone/restapi/tests/test_statictime.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,6 @@ def setUp(self):

setRoles(self.portal, TEST_USER_ID, ["Manager"])

registry = getUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings, check=False)
settings.globally_enabled = True

transaction.commit()

def create_document(self, id_):
Expand Down

0 comments on commit 681e642

Please sign in to comment.