Skip to content

Commit

Permalink
Merge pull request #244 from plone/maurits-globally-enable-comments
Browse files Browse the repository at this point in the history
Globally enable comments on install
  • Loading branch information
mauritsvanrees authored Sep 4, 2024
2 parents 9648d82 + 5129fb9 commit e08c5d8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 39 deletions.
3 changes: 2 additions & 1 deletion news/211.breaking
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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]
Installing this in the Add-ons control panel will enable comments globally.
[jensens]
2 changes: 1 addition & 1 deletion plone/app/discussion/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class IDiscussionSettings(Interface):
"objects before users will be able to post comments.",
),
required=False,
default=False,
default=True,
)

anonymous_comments = schema.Bool(
Expand Down
17 changes: 0 additions & 17 deletions plone/app/discussion/testing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
from plone.app.discussion.interfaces import IDiscussionSettings
from plone.app.robotframework.testing import REMOTE_LIBRARY_ROBOT_TESTING
from plone.app.testing import applyProfile
from plone.app.testing import FunctionalTesting
Expand All @@ -8,17 +7,7 @@
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.app.testing import TEST_USER_PASSWORD
from plone.registry.interfaces import IRegistry
from Products.CMFCore.utils import getToolByName
from zope.component import queryUtility


try:
import plone.app.collection # noqa

COLLECTION_TYPE = "Collection"
except ImportError:
COLLECTION_TYPE = "Topic"


class PloneAppDiscussion(PloneSandboxLayer):
Expand Down Expand Up @@ -105,12 +94,6 @@ class PloneAppDiscussionRobot(PloneAppDiscussion):
REMOTE_LIBRARY_ROBOT_TESTING,
)

def setUpPloneSite(self, portal):
applyProfile(portal, "plone.app.discussion:default")
registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings)
settings.globally_enabled = True


PLONE_APP_DISCUSSION_ROBOT_FIXTURE = PloneAppDiscussionRobot()
PLONE_APP_DISCUSSION_FIXTURE = PloneAppDiscussion()
Expand Down
31 changes: 12 additions & 19 deletions plone/app/discussion/tests/collection-integration-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ XXX: This functional test part has been removed due to the removal of
ATContentTypes from PLONE_FIXTURE. We have to rewrite this test as a robot
test because the dexterity collections do not work without js.

XXX To put this more plainly: this file is currently NOT tested.


List comments in a collection
-----------------------------
Expand All @@ -12,33 +14,24 @@ Create a collection.
>>> from plone.app.testing import TEST_USER_NAME
>>> setRoles(portal, 'manager', ['Manager'])
>>> browser.open(portal.absolute_url())
>>> from plone.app.discussion.testing import COLLECTION_TYPE
>>> browser.getLink(url='++add++' + COLLECTION_TYPE).click()
>>> browser.getLink(url='++add++Collection').click()
>>> open('/tmp/testbrowser.html', 'w').write(browser.contents)
>>> browser.getControl('form.widgets.IDublinCore.title').value = 'Foo Comment Collection'
>>> browser.getControl('Save').click()
>>> print(browser.contents)
<...Changes saved...
>>> topic_url = browser.url
>>> collection_url = browser.url

Set the collection criteria.

>>> browser.open(topic_url + "/edit")
>>> browser.open(collection_url + "/edit")

>>> if COLLECTION_TYPE == "Collection":
... browser.getControl(name="addindex").value = ['portal_type']
... browser.getControl(name="form.button.addcriteria").click()
... browser.getControl(name="addoperator").value = ['plone.app.querystring.operation.selection.any']
... browser.getControl(name="form.button.addcriteria").click()
... browser.getControl(name="query.v:records:list").value = ["Discussion Item"]
... browser.getControl(name="form.button.save").click()
... else:
... browser.getLink('Criteria').click()
... browser.getControl('Item Type', index=0).selected = True
... browser.getControl('Select content types').selected = True
... browser.getControl('Add criteria').click()
... browser.getControl('Comment').selected = True
... browser.getControl('Save', index=0).click()
>>> browser.getControl(name="addindex").value = ['portal_type']
... browser.getControl(name="form.button.addcriteria").click()
... browser.getControl(name="addoperator").value = ['plone.app.querystring.operation.selection.any']
... browser.getControl(name="form.button.addcriteria").click()
... browser.getControl(name="query.v:records:list").value = ["Discussion Item"]
... browser.getControl(name="form.button.save").click()
>>> print(browser.contents)
<...Changes saved...

Expand Down Expand Up @@ -71,7 +64,7 @@ Delete the commented content.

The comments are no longer in the catalog.

>>> browser.open(topic_url)
>>> browser.open(collection_url)
>>> browser.getLink('admin on Doc1', index=0)
Traceback (most recent call last):
LinkNotFoundError
Expand Down
2 changes: 1 addition & 1 deletion plone/app/discussion/tests/test_controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_globally_enabled(self):
"plone.app.discussion.interfaces."
+ "IDiscussionSettings.globally_enabled"
],
False,
True,
)

def test_anonymous_comments(self):
Expand Down

0 comments on commit e08c5d8

Please sign in to comment.