From 13772c6e5bba4aaebf95fc8c1bab6f8b3aad999e Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Tue, 30 Nov 2010 09:06:46 +0000 Subject: [PATCH] Redirect back to the discussion control panel when the discussion control panel form is submitted. svn path=/plone.app.discussion/trunk/; revision=46040 --- CHANGES.txt | 4 ++++ plone/app/discussion/browser/controlpanel.py | 21 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 5467b27..fbfee3a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,10 @@ Changelog 1.0RC1 (unreleased) ------------------- +- Redirect back to the discussion control panel when the discussion control + panel form is submitted. + [timo] + - Fix document_byline bottom margin if commenter images are disabled. [timo] diff --git a/plone/app/discussion/browser/controlpanel.py b/plone/app/discussion/browser/controlpanel.py index e774627..326347a 100644 --- a/plone/app/discussion/browser/controlpanel.py +++ b/plone/app/discussion/browser/controlpanel.py @@ -1,9 +1,12 @@ # -*- coding: utf-8 -*- +from Products.statusmessages.interfaces import IStatusMessage + from plone.app.registry.browser import controlpanel from plone.app.discussion.interfaces import IDiscussionSettings, _ +from z3c.form import button from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget @@ -45,6 +48,24 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm): self.widgets['user_notification_enabled'].label = \ _(u"User Email Notification") + @button.buttonAndHandler(_('Save'), name='save') + 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)) + class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper): form = DiscussionSettingsEditForm