merge master in filippo_moderation_js
This commit is contained in:
@@ -14,6 +14,7 @@ from zope.component import getMultiAdapter
|
||||
from zope.component import getUtility
|
||||
from zope.event import notify
|
||||
from zope.lifecycleevent import ObjectModifiedEvent
|
||||
from .comments import CommentForm
|
||||
|
||||
|
||||
class View(BrowserView):
|
||||
|
||||
@@ -17,6 +17,7 @@ from plone.z3cform import z2
|
||||
from plone.z3cform.fieldsets import extensible
|
||||
from plone.z3cform.interfaces import IWrappedForm
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
from Products.CMFPlone.utils import safe_unicode
|
||||
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
|
||||
from Products.statusmessages.interfaces import IStatusMessage
|
||||
from six.moves.urllib.parse import quote
|
||||
@@ -32,32 +33,30 @@ from zope.i18n import translate
|
||||
from zope.i18nmessageid import Message
|
||||
from zope.interface import alsoProvides
|
||||
|
||||
import six
|
||||
|
||||
|
||||
COMMENT_DESCRIPTION_PLAIN_TEXT = _(
|
||||
u'comment_description_plain_text',
|
||||
default=u'You can add a comment by filling out the form below. '
|
||||
u'Plain text formatting.'
|
||||
u'Plain text formatting.',
|
||||
)
|
||||
|
||||
COMMENT_DESCRIPTION_MARKDOWN = _(
|
||||
u'comment_description_markdown',
|
||||
default=u'You can add a comment by filling out the form below. '
|
||||
u'Plain text formatting. You can use the Markdown syntax for '
|
||||
u'links and images.'
|
||||
u'links and images.',
|
||||
)
|
||||
|
||||
COMMENT_DESCRIPTION_INTELLIGENT_TEXT = _(
|
||||
u'comment_description_intelligent_text',
|
||||
default=u'You can add a comment by filling out the form below. '
|
||||
u'Plain text formatting. Web and email addresses are '
|
||||
u'transformed into clickable links.'
|
||||
u'transformed into clickable links.',
|
||||
)
|
||||
|
||||
COMMENT_DESCRIPTION_MODERATION_ENABLED = _(
|
||||
u'comment_description_moderation_enabled',
|
||||
default=u'Comments are moderated.'
|
||||
default=u'Comments are moderated.',
|
||||
)
|
||||
|
||||
|
||||
@@ -152,13 +151,9 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
||||
|
||||
# Make sure author_name/ author_email is properly encoded
|
||||
if 'author_name' in data:
|
||||
author_name = data['author_name']
|
||||
if isinstance(author_name, str):
|
||||
author_name = six.text_type(author_name, 'utf-8')
|
||||
author_name = safe_unicode(data['author_name'])
|
||||
if 'author_email' in data:
|
||||
author_email = data['author_email']
|
||||
if isinstance(author_email, str):
|
||||
author_email = six.text_type(author_email, 'utf-8')
|
||||
author_email = safe_unicode(data['author_email'])
|
||||
|
||||
# Set comment author properties for anonymous users or members
|
||||
portal_membership = getToolByName(context, 'portal_membership')
|
||||
@@ -167,21 +162,18 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
||||
'Reply to item', context):
|
||||
# Member
|
||||
member = portal_membership.getAuthenticatedMember()
|
||||
# memberdata is stored as utf-8 encoded strings
|
||||
email = member.getProperty('email')
|
||||
email = safe_unicode(member.getProperty('email'))
|
||||
fullname = member.getProperty('fullname')
|
||||
if not fullname or fullname == '':
|
||||
fullname = member.getUserName()
|
||||
elif isinstance(fullname, str):
|
||||
fullname = six.text_type(fullname, 'utf-8')
|
||||
fullname = safe_unicode(fullname)
|
||||
author_name = fullname
|
||||
if email and isinstance(email, str):
|
||||
email = six.text_type(email, 'utf-8')
|
||||
# XXX: according to IComment interface author_email must not be
|
||||
email = safe_unicode(email)
|
||||
# XXX: according to IComment interface author_email must not be # noqa T000
|
||||
# set for logged in users, cite:
|
||||
# 'for anonymous comments only, set to None for logged in comments'
|
||||
author_email = email
|
||||
# /XXX
|
||||
# /XXX # noqa T000
|
||||
|
||||
return author_name, author_email
|
||||
|
||||
@@ -228,7 +220,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
||||
raise Unauthorized(
|
||||
u'Anonymous user tries to post a comment, but anonymous '
|
||||
u'commenting is disabled. Or user does not have the '
|
||||
u"'reply to item' permission."
|
||||
u"'reply to item' permission.",
|
||||
)
|
||||
|
||||
return comment
|
||||
@@ -240,10 +232,10 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
||||
|
||||
# Check if conversation is enabled on this content object
|
||||
if not self.__parent__.restrictedTraverse(
|
||||
'@@conversation_view'
|
||||
'@@conversation_view',
|
||||
).enabled():
|
||||
raise Unauthorized(
|
||||
'Discussion is not enabled for this content object.'
|
||||
'Discussion is not enabled for this content object.',
|
||||
)
|
||||
|
||||
# Validation form
|
||||
@@ -293,7 +285,7 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
||||
comment_review_state = workflowTool.getInfoFor(
|
||||
comment,
|
||||
'review_state',
|
||||
None
|
||||
None,
|
||||
)
|
||||
if comment_review_state == 'pending' and not can_review:
|
||||
# Show info message when comment moderation is enabled
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from plone.app.controlpanel.interfaces import IConfigurationChangedEvent
|
||||
from plone.app.discussion.interfaces import _
|
||||
from plone.app.discussion.interfaces import IDiscussionSettings
|
||||
from plone.app.discussion.upgrades import update_registry
|
||||
@@ -7,6 +6,7 @@ from plone.app.registry.browser import controlpanel
|
||||
from plone.registry.interfaces import IRecordModifiedEvent
|
||||
from plone.registry.interfaces import IRegistry
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
from Products.CMFPlone.interfaces.controlpanel import IConfigurationChangedEvent # noqa: E501
|
||||
from Products.CMFPlone.interfaces.controlpanel import IMailSchema
|
||||
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
|
||||
from Products.statusmessages.interfaces import IStatusMessage
|
||||
@@ -34,7 +34,7 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
|
||||
u'To enable the moderation workflow for comments, '
|
||||
u'go to the Types Control Panel, choose '
|
||||
u'"Comment" and set workflow to '
|
||||
u'"Comment Review Workflow".'
|
||||
u'"Comment Review Workflow".',
|
||||
)
|
||||
|
||||
def updateFields(self):
|
||||
@@ -68,10 +68,10 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
|
||||
self.widgets['anonymous_comments'].label = _(u'Anonymous Comments')
|
||||
self.widgets['show_commenter_image'].label = _(u'Commenter Image')
|
||||
self.widgets['moderator_notification_enabled'].label = _(
|
||||
u'Moderator Email Notification'
|
||||
u'Moderator Email Notification',
|
||||
)
|
||||
self.widgets['user_notification_enabled'].label = _(
|
||||
u'User Email Notification'
|
||||
u'User Email Notification',
|
||||
)
|
||||
|
||||
@button.buttonAndHandler(_('Save'), name=None)
|
||||
@@ -92,8 +92,8 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
|
||||
self.request.response.redirect(
|
||||
'{0}/{1}'.format(
|
||||
self.context.absolute_url(),
|
||||
self.control_panel_view
|
||||
)
|
||||
self.control_panel_view,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user