コード例 #1
0
class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
    """Discussion settings form.
    """
    schema = IDiscussionSettings
    id = "DiscussionSettingsEditForm"
    label = _(u"Discussion settings")
    description = _(
        u"help_discussion_settings_editform",
        default=u"Some discussion related settings are not located "
        "in the Discussion Control Panel.\n"
        "To enable comments for a specific content type, "
        "go to the Types Control Panel of this type and "
        "choose \"Allow comments\".\n"
        "To enable the moderation workflow for comments, "
        "go to the Types Control Panel, choose "
        "\"Comment\" and set workflow to "
        "\"Comment Review Workflow\".")

    def updateFields(self):
        super(DiscussionSettingsEditForm, self).updateFields()
        self.fields['globally_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['moderation_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['anonymous_comments'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['show_commenter_image'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['moderator_notification_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['user_notification_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget

    def updateWidgets(self):
        super(DiscussionSettingsEditForm, self).updateWidgets()
        self.widgets['globally_enabled'].label = _(u"Enable Comments")
        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")
        self.widgets['user_notification_enabled'].label = \
            _(u"User Email Notification")

    @button.buttonAndHandler(_('Save'), name=None)
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        changes = self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                      "info")
        self.context.REQUEST.RESPONSE.redirect("@@discussion-settings")

    @button.buttonAndHandler(_('Cancel'), name='cancel')
    def handleCancel(self, action):
        IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                      "info")
        self.request.response.redirect(
            "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
コード例 #2
0
 def updateWidgets(self):
     super(DiscussionSettingsEditForm, self).updateWidgets()
     self.widgets['globally_enabled'].label = _(u"Enable Comments")
     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")
     self.widgets['user_notification_enabled'].label = \
         _(u"User Email Notification")
コード例 #3
0
 def updateWidgets(self):
     super(DiscussionSettingsEditForm, self).updateWidgets()
     self.widgets['globally_enabled'].label = _(u"Enable Comments")
     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")
     self.widgets['user_notification_enabled'].label = \
         _(u"User Email Notification")
コード例 #4
0
 def updateWidgets(self):
     try:
         super(DiscussionSettingsEditForm, self).updateWidgets()
     except KeyError:
         # upgrade profile not visible in prefs_install_products_form
         # provide auto-upgrade
         update_registry(self.context)
         super(DiscussionSettingsEditForm, self).updateWidgets()
     self.widgets['globally_enabled'].label = _(u"Enable Comments")
     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")
     self.widgets['user_notification_enabled'].label = \
         _(u"User Email Notification")
コード例 #5
0
 def updateWidgets(self):
     try:
         super(DiscussionSettingsEditForm, self).updateWidgets()
     except KeyError:
         # upgrade profile not visible in prefs_install_products_form
         # provide auto-upgrade
         update_registry(self.context)
         super(DiscussionSettingsEditForm, self).updateWidgets()
     self.widgets['globally_enabled'].label = _(u"Enable Comments")
     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")
     self.widgets['user_notification_enabled'].label = \
         _(u"User Email Notification")
コード例 #6
0
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u'Edit cancelled'),
                                                   'info')
     self.request.response.redirect(
         '{0}/{1}'.format(
             self.context.absolute_url(),
             self.control_panel_view
         )
     )
コード例 #7
0
 def handleSave(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(_(u'Changes saved'),
                                                   'info')
     self.context.REQUEST.RESPONSE.redirect('@@discussion-controlpanel')
コード例 #8
0
 def handleSave(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     changes = self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                   "info")
     self.context.REQUEST.RESPONSE.redirect("@@discussion-settings")
コード例 #9
0
 def handleSave(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"),
                                                   "info")
     self.context.REQUEST.RESPONSE.redirect("@@discussion-settings")
コード例 #10
0
 def handleSave(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     self.applyChanges(data)
     IStatusMessage(self.request).addStatusMessage(_(u'Changes saved'),
                                                   'info')
     self.context.REQUEST.RESPONSE.redirect('@@discussion-controlpanel')
コード例 #11
0
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u'Edit cancelled'),
                                                   'info')
     self.request.response.redirect(
         '{0}/{1}'.format(
             self.context.absolute_url(),
             self.control_panel_view
         )
     )
コード例 #12
0
 def __call__(self):
     comment = aq_inner(self.context)
     conversation = aq_parent(comment)
     content_object = aq_parent(conversation)
     del conversation[comment.id]
     IStatusMessage(self.context.REQUEST).addStatusMessage(_("Comment deleted."), type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     if len(came_from) == 0:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #13
0
 def __call__(self):
     comment = aq_inner(self.context)
     conversation = aq_parent(comment)
     content_object = aq_parent(conversation)
     del conversation[comment.id]
     IStatusMessage(self.context.REQUEST).addStatusMessage(
         _("Comment deleted."), type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     # if the referrer already has a came_from in it, don't redirect back
     if len(came_from) == 0 or 'came_from=' in came_from:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #14
0
 def __call__(self):
     comment = aq_inner(self.context)
     conversation = aq_parent(comment)
     content_object = aq_parent(conversation)
     del conversation[comment.id]
     IStatusMessage(self.context.REQUEST).addStatusMessage(
         _("Comment deleted."),
         type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     if len(came_from) == 0:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #15
0
 def __call__(self):
     comment = aq_inner(self.context)
     content_object = aq_parent(aq_parent(comment))
     workflowTool = getToolByName(comment, "portal_workflow", None)
     current_state = workflowTool.getInfoFor(comment, "review_state")
     if current_state != "published":
         workflowTool.doActionFor(comment, "publish")
     catalogTool = getToolByName(comment, "portal_catalog")
     catalogTool.reindexObject(comment)
     IStatusMessage(self.context.REQUEST).addStatusMessage(_("Comment approved."), type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     if len(came_from) == 0:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #16
0
 def __call__(self):
     comment = aq_inner(self.context)
     conversation = aq_parent(comment)
     content_object = aq_parent(conversation)
     del conversation[comment.id]
     content_object.reindexObject(idxs=['total_comments'])
     IStatusMessage(self.context.REQUEST).addStatusMessage(
         _("Comment deleted."),
         type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     # if the referrer already has a came_from in it, don't redirect back
     if len(came_from) == 0 or 'came_from=' in came_from:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #17
0
 def __call__(self):
     comment = aq_inner(self.context)
     content_object = aq_parent(aq_parent(comment))
     workflowTool = getToolByName(comment, 'portal_workflow', None)
     workflow_action = self.request.form.get('workflow_action', 'publish')
     workflowTool.doActionFor(comment, workflow_action)
     comment.reindexObject()
     content_object.reindexObject(idxs=['total_comments'])
     IStatusMessage(self.context.REQUEST).addStatusMessage(
         _("Comment approved."), type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     # if the referrer already has a came_from in it, don't redirect back
     if len(came_from) == 0 or 'came_from=' in came_from:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #18
0
 def __call__(self):
     comment = aq_inner(self.context)
     content_object = aq_parent(aq_parent(comment))
     workflowTool = getToolByName(comment, 'portal_workflow', None)
     workflow_action = self.request.form.get('workflow_action', 'publish')
     workflowTool.doActionFor(comment, workflow_action)
     comment.reindexObject()
     content_object.reindexObject(idxs=['total_comments'])
     IStatusMessage(self.context.REQUEST).addStatusMessage(
         _("Comment approved."),
         type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     # if the referrer already has a came_from in it, don't redirect back
     if len(came_from) == 0 or 'came_from=' in came_from:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #19
0
 def __call__(self):
     comment = aq_inner(self.context)
     content_object = aq_parent(aq_parent(comment))
     workflowTool = getToolByName(comment, 'portal_workflow', None)
     current_state = workflowTool.getInfoFor(comment, 'review_state')
     if current_state != 'published':
         workflowTool.doActionFor(comment, 'publish')
     comment.reindexObject()
     content_object.reindexObject()
     IStatusMessage(self.context.REQUEST).addStatusMessage(
         _("Comment approved."), type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     # if the referrer already has a came_from in it, don't redirect back
     if len(came_from) == 0 or 'came_from=' in came_from:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #20
0
 def __call__(self):
     comment = aq_inner(self.context)
     content_object = aq_parent(aq_parent(comment))
     workflowTool = getToolByName(comment, 'portal_workflow', None)
     current_state = workflowTool.getInfoFor(comment, 'review_state')
     if current_state != 'published':
         workflowTool.doActionFor(comment, 'publish')
     comment.reindexObject()
     content_object.reindexObject()
     IStatusMessage(self.context.REQUEST).addStatusMessage(
         _("Comment approved."),
         type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     # if the referrer already has a came_from in it, don't redirect back
     if len(came_from) == 0 or 'came_from=' in came_from:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #21
0
 def __call__(self):
     comment = aq_inner(self.context)
     conversation = aq_parent(comment)
     content_object = aq_parent(conversation)
     # conditional security
     # base ZCML condition zope2.deleteObject allows 'delete own object'
     # modify this for 'delete_own_comment_allowed' controlpanel setting
     if self.can_delete(comment):
         del conversation[comment.id]
         content_object.reindexObject()
         IStatusMessage(self.context.REQUEST).addStatusMessage(
             _("Comment deleted."), type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     # if the referrer already has a came_from in it, don't redirect back
     if len(came_from) == 0 or 'came_from=' in came_from:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #22
0
def captcha_vocabulary(context):
    """Vocabulary with all available captcha implementations.
    """
    terms = []
    terms.append(SimpleTerm(value="disabled", token="disabled", title=_(u"Disabled")))

    if HAS_CAPTCHA:  # pragma: no cover
        terms.append(SimpleTerm(value="captcha", token="captcha", title="Captcha"))

    if HAS_RECAPTCHA:  # pragma: no cover
        terms.append(SimpleTerm(value="recaptcha", token="recaptcha", title="ReCaptcha"))

    if HAS_AKISMET:  # pragma: no cover
        terms.append(SimpleTerm(value="akismet", token="akismet", title="Akismet"))

    if HAS_NOROBOTS:  # pragma: no cover
        terms.append(SimpleTerm(value="norobots", token="norobots", title="Norobots"))
    return SimpleVocabulary(terms)
コード例 #23
0
 def __call__(self):
     comment = aq_inner(self.context)
     conversation = aq_parent(comment)
     content_object = aq_parent(conversation)
     # conditional security
     # base ZCML condition zope2.deleteObject allows 'delete own object'
     # modify this for 'delete_own_comment_allowed' controlpanel setting
     if self.can_delete(comment):
         del conversation[comment.id]
         content_object.reindexObject()
         IStatusMessage(self.context.REQUEST).addStatusMessage(
             _("Comment deleted."),
             type="info")
     came_from = self.context.REQUEST.HTTP_REFERER
     # if the referrer already has a came_from in it, don't redirect back
     if len(came_from) == 0 or 'came_from=' in came_from:
         came_from = content_object.absolute_url()
     return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #24
0
def DeleteComment__call__(self):
    comment = aq_inner(self.context)
    conversation = aq_parent(comment)
    content_object = aq_parent(conversation)
    # conditional security
    # base ZCML condition zope2.deleteObject allows 'delete own object'
    # modify this for 'delete_own_comment_allowed' controlpanel setting
    # can_delete was introduced in 2.3.3.
    if not base_hasattr(self, 'can_delete') or self.can_delete(comment):
        del conversation[comment.id]
        content_object.reindexObject()
        IStatusMessage(self.context.REQUEST).addStatusMessage(
            _('Comment deleted.'), type='info')
    came_from = self.context.REQUEST.HTTP_REFERER
    # if the referrer already has a came_from in it, don't redirect back
    if (len(came_from) == 0 or 'came_from=' in came_from or not getToolByName(
            content_object, 'portal_url').isURLInPortal(came_from)):
        came_from = content_object.absolute_url()
    return self.context.REQUEST.RESPONSE.redirect(came_from)
コード例 #25
0
def captcha_vocabulary(context):
    """Vocabulary with all available captcha implementations.
    """
    terms = []
    terms.append(
        SimpleTerm(
            value='disabled',
            token='disabled',
            title=_(u'Disabled')))

    if HAS_CAPTCHA:  # pragma: no cover
        terms.append(
            SimpleTerm(
                value='captcha',
                token='captcha',
                title='Captcha'))

    if HAS_RECAPTCHA:  # pragma: no cover
        terms.append(
            SimpleTerm(
                value='recaptcha',
                token='recaptcha',
                title='ReCaptcha'))

    if HAS_AKISMET:  # pragma: no cover
        terms.append(
            SimpleTerm(
                value='akismet',
                token='akismet',
                title='Akismet'))

    if HAS_NOROBOTS:  # pragma: no cover
        terms.append(
            SimpleTerm(
                value='norobots',
                token='norobots',
                title='Norobots'))
    return SimpleVocabulary(terms)
コード例 #26
0
def captcha_vocabulary(context):
    """Vocabulary with all available captcha implementations.
    """
    terms = []
    terms.append(
        SimpleTerm(
            value='disabled',
            token='disabled',
            title=_(u'Disabled')))

    if HAS_CAPTCHA: # pragma: no cover
        terms.append(
            SimpleTerm(
                value='captcha',
                token='captcha',
                title='Captcha'))

    if HAS_RECAPTCHA: # pragma: no cover
        terms.append(
            SimpleTerm(
                value='recaptcha',
                token='recaptcha',
                title='ReCaptcha'))

    if HAS_AKISMET: # pragma: no cover
        terms.append(
            SimpleTerm(
                value='akismet',
                token='akismet',
                title='Akismet'))

    if HAS_NOROBOTS: # pragma: no cover
        terms.append(
            SimpleTerm(
                value='norobots',
                token='norobots',
                title='Norobots'))
    return SimpleVocabulary(terms)
コード例 #27
0
class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
    """Discussion settings form.
    """
    schema = IDiscussionSettings
    id = 'DiscussionSettingsEditForm'
    label = _(u'Discussion settings')
    description = _(
        u'help_discussion_settings_editform',
        default=u'Some discussion related settings are not '
                u'located in the Discussion Control Panel.\n'
                u'To enable comments for a specific content type, '
                u'go to the Types Control Panel of this type and '
                u'choose "Allow comments".\n'
                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".'
    )

    def updateFields(self):
        super(DiscussionSettingsEditForm, self).updateFields()
        self.fields['globally_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['moderation_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['edit_comment_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['delete_own_comment_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['anonymous_comments'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['show_commenter_image'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['moderator_notification_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget
        self.fields['user_notification_enabled'].widgetFactory = \
            SingleCheckBoxFieldWidget

    def updateWidgets(self):
        try:
            super(DiscussionSettingsEditForm, self).updateWidgets()
        except KeyError:
            # upgrade profile not visible in prefs_install_products_form
            # provide auto-upgrade
            update_registry(self.context)
            super(DiscussionSettingsEditForm, self).updateWidgets()
        self.widgets['globally_enabled'].label = _(u'Enable Comments')
        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'
        )
        self.widgets['user_notification_enabled'].label = _(
            u'User Email Notification'
        )

    @button.buttonAndHandler(_('Save'), name=None)
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(_(u'Changes saved'),
                                                      'info')
        self.context.REQUEST.RESPONSE.redirect('@@discussion-controlpanel')

    @button.buttonAndHandler(_('Cancel'), name='cancel')
    def handleCancel(self, action):
        IStatusMessage(self.request).addStatusMessage(_(u'Edit cancelled'),
                                                      'info')
        self.request.response.redirect(
            '{0}/{1}'.format(
                self.context.absolute_url(),
                self.control_panel_view
            )
        )
コード例 #28
0
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                   "info")
     self.request.response.redirect("%s/%s" % (self.context.absolute_url(),
                                               self.control_panel_view))
コード例 #29
0
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled"),
                                                   "info")
     self.request.response.redirect(
         "%s/%s" % (self.context.absolute_url(), self.control_panel_view))