[zeam.form.silva][Sylvain Viollon] Add a cancel configuration bu...
[email protected] Fri, 25 Oct 2013 18:14:11 +0200
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: Sylvain Viollon
date: Fri Oct 25 18:14:06 2013 +0200
revision: 428:ee0922e47cb5 in zeam.form.silva
branch: 2.4
details: https://hg.infrae.com/zeam.form.silva?cmd=changeset;node=ee0922e47cb5
modified: src/zeam/form/silva/__init__.py src/zeam/form/silva/actions.py
added:
removed:
log: Add a cancel configuration button.
diffstat:
src/zeam/form/silva/__init__.py | 1 +
src/zeam/form/silva/actions.py | 18 +++++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diffs (65 lines):
diff -r 5886567a3376 -r ee0922e47cb5 src/zeam/form/silva/__init__.py
--- a/src/zeam/form/silva/__init__.py Fri Oct 25 15:56:43 2013 +0200
+++ b/src/zeam/form/silva/__init__.py Fri Oct 25 18:14:06 2013 +0200
@@ -28,6 +28,7 @@
from .datamanager import SilvaDataManager, FieldValueDataManagerFactory
from .actions import ExtractedDecoratedAction, LinkAction
from .actions import EditAction, CancelAction, PopupAction
+from .actions import CancelConfigurationAction
from .validation import DefaultFormLookup
from .interfaces import IDefaultAction, IRemoverAction
diff -r 5886567a3376 -r ee0922e47cb5 src/zeam/form/silva/actions.py
--- a/src/zeam/form/silva/actions.py Fri Oct 25 15:56:43 2013 +0200
+++ b/src/zeam/form/silva/actions.py Fri Oct 25 18:14:06 2013 +0200
@@ -7,7 +7,7 @@
from five import grok
from zope.interface import Interface
-from silva.core.interfaces import IRoot
+from silva.core.interfaces import IRoot, ISilvaService
from silva.core.interfaces.errors import ContentError
from silva.translations import translate as _
@@ -104,12 +104,13 @@
class CancelAction(Action):
- """A action to cancel
+ """An action to cancel
"""
grok.implements(IRESTCloseAction, ICancelerAction)
title = _(u"Cancel")
description = _(u"Go back to the previous screen")
accesskey = u'ctrl+z'
+ screen = 'content'
def getRedirectedContent(self, form):
return form.context
@@ -126,6 +127,17 @@
u"Go back to the folder view without adding the item")
+class CancelConfigurationAction(CancelAction):
+ description = _(u'Go back to the site preferences')
+ screen = 'admin'
+
+ def getRedirectedContent(self, form):
+ content = form.context
+ if ISilvaService.providedBy(content):
+ return aq_parent(aq_inner(content))
+ return content
+
+
class CancelEditAction(CancelAction):
"""Cancel an edit action.
"""
@@ -146,7 +158,7 @@
def update(self):
super(SMICancelWidget, self).update()
- self.screen = 'content'
+ self.screen = self.component.screen
self.contentPath = self.form.get_content_path(
self.component.getRedirectedContent(self.form))