Repository: Products.CMFPlone
Branch: refs/heads/master
Date: 2014-12-22T11:50:28+01:00
Author: Timo Stollenwerk () <contact@timostollenwerk.net>
Commit: https://github.com/plone/Products.CMFPlone/commit/4faf20d4c872427be4fa9657f14a2813474aba7a

Move syndication control panel from plone.app.controlpanel to CMFPlone.

Files changed:
A Products/CMFPlone/controlpanel/browser/syndication.py
M Products/CMFPlone/controlpanel/browser/configure.zcml

diff --git a/Products/CMFPlone/controlpanel/browser/configure.zcml b/Products/CMFPlone/controlpanel/browser/configure.zcml
index 1ef3589..ac77cbc 100644
--- a/Products/CMFPlone/controlpanel/browser/configure.zcml
+++ b/Products/CMFPlone/controlpanel/browser/configure.zcml
@@ -123,6 +123,14 @@
     permission="plone.app.controlpanel.Markup"
     />
 
+  <!-- Syndication Control Panel -->
+  <browser:page
+      for="Products.CMFPlone.interfaces.IPloneSiteRoot"
+      name="syndication-settings"
+      class=".syndication.SyndicationControlPanel"
+      permission="cmf.ManagePortal"
+      />
+
   <!-- Usergroup Control Panel -->
   <browser:page
     name="usergroup-controlpanel"
diff --git a/Products/CMFPlone/controlpanel/browser/syndication.py b/Products/CMFPlone/controlpanel/browser/syndication.py
new file mode 100644
index 0000000..912b825
--- /dev/null
+++ b/Products/CMFPlone/controlpanel/browser/syndication.py
@@ -0,0 +1,97 @@
+from Products.CMFCore.utils import getToolByName
+from zope.component import getUtility
+from plone.registry.interfaces import IRegistry
+from zope.i18nmessageid import MessageFactory
+from Products.CMFPlone.interfaces.syndication import ISiteSyndicationSettings
+from plone.app.registry.browser import controlpanel
+from z3c.form import button
+from Products.statusmessages.interfaces import IStatusMessage
+
+_ = MessageFactory('plone')
+
+
+class SyndicationControlPanelForm(controlpanel.RegistryEditForm):
+    schema = ISiteSyndicationSettings
+    label = _(u'Syndication Settings')
+    description = _(u'Default syndication settings.')
+
+    def getSyndicationSettingsButtonShown(self):
+        actions = getToolByName(self.context, 'portal_actions')
+        if 'syndication' in actions.object.objectIds():
+            return actions.object.syndication.getProperty('visible')
+        else:
+            IStatusMessage(self.request).addStatusMessage(
+                _(u"Missing syndication settings action."), "warn")
+
+    def getSyndicationLinkShown(self):
+        actions = getToolByName(self.context, 'portal_actions')
+        if 'rss' in actions.document_actions.objectIds():
+            return actions.document_actions.rss.getProperty('visible')
+        else:
+            IStatusMessage(self.request).addStatusMessage(
+                _(u"Missing rss link action."), "warn")
+
+    def forceCheckboxValue(self, widget, checked):
+        if checked:
+            widget.value = ['selected']
+        else:
+            widget.value = []
+        for item in widget.items:
+            if 'checked' in item:
+                if checked:
+                    item['checked'] = True
+                else:
+                    item['checked'] = False
+
+    def update(self):
+        super(SyndicationControlPanelForm, self).update()
+
+        # We override this so we can get actual
+        # settings for portal_actions related settings
+        content = self.getContent()
+        show_settings_btn = self.getSyndicationSettingsButtonShown()
+        if show_settings_btn != content.show_syndication_button:
+            self.forceCheckboxValue(
+                self.widgets['show_syndication_button'], show_settings_btn)
+        show_link_btn = self.getSyndicationLinkShown()
+        if show_link_btn != content.show_syndication_link:
+            self.forceCheckboxValue(
+                self.widgets['show_syndication_link'], show_link_btn)
+
+    def setSyndicationActionSettings(self, data):
+        actions = getToolByName(self.context, 'portal_actions')
+        if 'syndication' in actions.object.objectIds():
+            actions.object.syndication._setPropValue(
+                'visible', data['show_syndication_button'])
+        if 'rss' in actions.document_actions.objectIds():
+            actions.document_actions.rss._setPropValue(
+                'visible', data['show_syndication_link'])
+
+    @button.buttonAndHandler(_(u"Save"), name='save')
+    def handleSave(self, action):
+        """
+        Again, we're customizing this to handle saving
+        portal_actions related setting data.
+        """
+        data, errors = self.extractData()
+        if errors:
+            self.status = self.formErrorsMessage
+            return
+
+        self.setSyndicationActionSettings(data)
+        self.applyChanges(data)
+        IStatusMessage(self.request).addStatusMessage(
+            _(u"Changes saved."), "info")
+        self.request.response.redirect("%s/%s" % (
+            self.context.absolute_url(), self.control_panel_view))
+
+    @button.buttonAndHandler(_(u"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 SyndicationControlPanel(controlpanel.ControlPanelFormWrapper):
+    form = SyndicationControlPanelForm


Repository: Products.CMFPlone
Branch: refs/heads/master
Date: 2014-12-22T11:53:29+01:00
Author: Timo Stollenwerk () <contact@timostollenwerk.net>
Commit: https://github.com/plone/Products.CMFPlone/commit/55eed5220f2f7dc3937d66183e7d43a1c51a6bb8

Rename syndication-settings to syndication-controlpanel. Keep the old view registration for backwards compatibility.

Files changed:
M Products/CMFPlone/controlpanel/browser/configure.zcml
M Products/CMFPlone/profiles/default/controlpanel.xml

diff --git a/Products/CMFPlone/controlpanel/browser/configure.zcml b/Products/CMFPlone/controlpanel/browser/configure.zcml
index ac77cbc..2bc0e18 100644
--- a/Products/CMFPlone/controlpanel/browser/configure.zcml
+++ b/Products/CMFPlone/controlpanel/browser/configure.zcml
@@ -125,11 +125,17 @@
 
   <!-- Syndication Control Panel -->
   <browser:page
-      for="Products.CMFPlone.interfaces.IPloneSiteRoot"
-      name="syndication-settings"
-      class=".syndication.SyndicationControlPanel"
-      permission="cmf.ManagePortal"
-      />
+    for="Products.CMFPlone.interfaces.IPloneSiteRoot"
+    name="syndication-controlpanel"
+    class=".syndication.SyndicationControlPanel"
+    permission="cmf.ManagePortal"
+    />
+  <browser:page
+    for="Products.CMFPlone.interfaces.IPloneSiteRoot"
+    name="syndication-settings"
+    class=".syndication.SyndicationControlPanel"
+    permission="cmf.ManagePortal"
+    />
 
   <!-- Usergroup Control Panel -->
   <browser:page
diff --git a/Products/CMFPlone/profiles/default/controlpanel.xml b/Products/CMFPlone/profiles/default/controlpanel.xml
index a0806d2..3521d29 100644
--- a/Products/CMFPlone/profiles/default/controlpanel.xml
+++ b/Products/CMFPlone/profiles/default/controlpanel.xml
@@ -150,7 +150,7 @@
  <configlet title="Syndication" action_id="syndication" appId="Plone"
     category="Plone" condition_expr=""
     icon_expr="string:$portal_url/rss.png"
-    url_expr="string:${portal_url}/@@syndication-settings" visible="True"
+    url_expr="string:${portal_url}/@@syndication-controlpanel" visible="True"
     i18n:attributes="title">
   <permission>Plone Site Setup: Site</permission>
  </configlet>


Repository: Products.CMFPlone
Branch: refs/heads/master
Date: 2014-12-22T11:54:53+01:00
Author: Timo Stollenwerk () <contact@timostollenwerk.net>
Commit: https://github.com/plone/Products.CMFPlone/commit/e7ee0242353b2c862c90825edcc19164e72e826b

Rename syndication-settings to syndication-controlpanel. Keep the old view registration for backwards compatibility.

Files changed:
M CHANGES.rst

diff --git a/CHANGES.rst b/CHANGES.rst
index a84e79c..1022984 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -8,6 +8,9 @@ Changelog
 5.0b1 (unreleased)
 ------------------
 
+- Rename syndication-settings to syndication-controlpanel. Keep the old view registration for backwards compatibility.
+  [timo]
+
 - Added a link for the advanced 'Create a Plone site' screen to the Plone overview.
   [jaroel]
 


Repository: Products.CMFPlone
Branch: refs/heads/master
Date: 2014-12-22T13:18:50+01:00
Author: Timo Stollenwerk (tisto) <tisto@plone.org>
Commit: https://github.com/plone/Products.CMFPlone/commit/627de97c02e7b0f081b51ffa6bd623631fe96e2b

Merge pull request #340 from plone/plip10359-syndication

Plip10359 syndication

Files changed:
A Products/CMFPlone/controlpanel/browser/syndication.py
M CHANGES.rst
M Products/CMFPlone/controlpanel/browser/configure.zcml
M Products/CMFPlone/profiles/default/controlpanel.xml

diff --git a/CHANGES.rst b/CHANGES.rst
index a84e79c..1022984 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -8,6 +8,9 @@ Changelog
 5.0b1 (unreleased)
 ------------------
 
+- Rename syndication-settings to syndication-controlpanel. Keep the old view registration for backwards compatibility.
+  [timo]
+
 - Added a link for the advanced 'Create a Plone site' screen to the Plone overview.
   [jaroel]
 
diff --git a/Products/CMFPlone/controlpanel/browser/configure.zcml b/Products/CMFPlone/controlpanel/browser/configure.zcml
index 1ef3589..2bc0e18 100644
--- a/Products/CMFPlone/controlpanel/browser/configure.zcml
+++ b/Products/CMFPlone/controlpanel/browser/configure.zcml
@@ -123,6 +123,20 @@
     permission="plone.app.controlpanel.Markup"
     />
 
+  <!-- Syndication Control Panel -->
+  <browser:page
+    for="Products.CMFPlone.interfaces.IPloneSiteRoot"
+    name="syndication-controlpanel"
+    class=".syndication.SyndicationControlPanel"
+    permission="cmf.ManagePortal"
+    />
+  <browser:page
+    for="Products.CMFPlone.interfaces.IPloneSiteRoot"
+    name="syndication-settings"
+    class=".syndication.SyndicationControlPanel"
+    permission="cmf.ManagePortal"
+    />
+
   <!-- Usergroup Control Panel -->
   <browser:page
     name="usergroup-controlpanel"
diff --git a/Products/CMFPlone/controlpanel/browser/syndication.py b/Products/CMFPlone/controlpanel/browser/syndication.py
new file mode 100644
index 0000000..912b825
--- /dev/null
+++ b/Products/CMFPlone/controlpanel/browser/syndication.py
@@ -0,0 +1,97 @@
+from Products.CMFCore.utils import getToolByName
+from zope.component import getUtility
+from plone.registry.interfaces import IRegistry
+from zope.i18nmessageid import MessageFactory
+from Products.CMFPlone.interfaces.syndication import ISiteSyndicationSettings
+from plone.app.registry.browser import controlpanel
+from z3c.form import button
+from Products.statusmessages.interfaces import IStatusMessage
+
+_ = MessageFactory('plone')
+
+
+class SyndicationControlPanelForm(controlpanel.RegistryEditForm):
+    schema = ISiteSyndicationSettings
+    label = _(u'Syndication Settings')
+    description = _(u'Default syndication settings.')
+
+    def getSyndicationSettingsButtonShown(self):
+        actions = getToolByName(self.context, 'portal_actions')
+        if 'syndication' in actions.object.objectIds():
+            return actions.object.syndication.getProperty('visible')
+        else:
+            IStatusMessage(self.request).addStatusMessage(
+                _(u"Missing syndication settings action."), "warn")
+
+    def getSyndicationLinkShown(self):
+        actions = getToolByName(self.context, 'portal_actions')
+        if 'rss' in actions.document_actions.objectIds():
+            return actions.document_actions.rss.getProperty('visible')
+        else:
+            IStatusMessage(self.request).addStatusMessage(
+                _(u"Missing rss link action."), "warn")
+
+    def forceCheckboxValue(self, widget, checked):
+        if checked:
+            widget.value = ['selected']
+        else:
+            widget.value = []
+        for item in widget.items:
+            if 'checked' in item:
+                if checked:
+                    item['checked'] = True
+                else:
+                    item['checked'] = False
+
+    def update(self):
+        super(SyndicationControlPanelForm, self).update()
+
+        # We override this so we can get actual
+        # settings for portal_actions related settings
+        content = self.getContent()
+        show_settings_btn = self.getSyndicationSettingsButtonShown()
+        if show_settings_btn != content.show_syndication_button:
+            self.forceCheckboxValue(
+                self.widgets['show_syndication_button'], show_settings_btn)
+        show_link_btn = self.getSyndicationLinkShown()
+        if show_link_btn != content.show_syndication_link:
+            self.forceCheckboxValue(
+                self.widgets['show_syndication_link'], show_link_btn)
+
+    def setSyndicationActionSettings(self, data):
+        actions = getToolByName(self.context, 'portal_actions')
+        if 'syndication' in actions.object.objectIds():
+            actions.object.syndication._setPropValue(
+                'visible', data['show_syndication_button'])
+        if 'rss' in actions.document_actions.objectIds():
+            actions.document_actions.rss._setPropValue(
+                'visible', data['show_syndication_link'])
+
+    @button.buttonAndHandler(_(u"Save"), name='save')
+    def handleSave(self, action):
+        """
+        Again, we're customizing this to handle saving
+        portal_actions related setting data.
+        """
+        data, errors = self.extractData()
+        if errors:
+            self.status = self.formErrorsMessage
+            return
+
+        self.setSyndicationActionSettings(data)
+        self.applyChanges(data)
+        IStatusMessage(self.request).addStatusMessage(
+            _(u"Changes saved."), "info")
+        self.request.response.redirect("%s/%s" % (
+            self.context.absolute_url(), self.control_panel_view))
+
+    @button.buttonAndHandler(_(u"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 SyndicationControlPanel(controlpanel.ControlPanelFormWrapper):
+    form = SyndicationControlPanelForm
diff --git a/Products/CMFPlone/profiles/default/controlpanel.xml b/Products/CMFPlone/profiles/default/controlpanel.xml
index a0806d2..3521d29 100644
--- a/Products/CMFPlone/profiles/default/controlpanel.xml
+++ b/Products/CMFPlone/profiles/default/controlpanel.xml
@@ -150,7 +150,7 @@
  <configlet title="Syndication" action_id="syndication" appId="Plone"
     category="Plone" condition_expr=""
     icon_expr="string:$portal_url/rss.png"
-    url_expr="string:${portal_url}/@@syndication-settings" visible="True"
+    url_expr="string:${portal_url}/@@syndication-controlpanel" visible="True"
     i18n:attributes="title">
   <permission>Plone Site Setup: Site</permission>
  </configlet>