Skip to content

Commit

Permalink
fix plone 5 compatibility for site controlpanel customization
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Sep 15, 2017
1 parent 68cb3c9 commit b64c62a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 23 deletions.
33 changes: 19 additions & 14 deletions collective/analyticspanel/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="collective.analyticspanel">

<browser:resourceDirectory
Expand All @@ -18,20 +19,24 @@
layer="..interfaces.IAnalyticsPanelLayer"
/>

<!--
TODO: hide webstats_js field (plone 4/5 compatible)
zcml:condition="have plone-5"
zcml:condition="have plone-4"
<browser:page
name="site-controlpanel"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".site.SiteControlPanel"
permission="cmf.ManagePortal"
layer="..interfaces.IAnalyticsPanelLayer"
/>
-->
<!--hide webstats_js field (plone 4/5 compatible) -->

<browser:page
name="site-controlpanel"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".site_p4.SiteControlPanel"
permission="cmf.ManagePortal"
layer="..interfaces.IAnalyticsPanelLayer"
zcml:condition="not-have plone-5"
/>
<browser:page
name="site-controlpanel"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".site.SiteControlPanel"
permission="cmf.ManagePortal"
layer="..interfaces.IAnalyticsPanelLayer"
zcml:condition="have plone-5"
/>

<!-- Plone default footer viewlet -->
<browser:viewlet
Expand Down
19 changes: 12 additions & 7 deletions collective/analyticspanel/browser/site.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# -*- coding: utf-8 -*-

from zope.formlib.form import FormFields
from plone.app.controlpanel.site import ISiteSchema
from plone.app.controlpanel.site import SiteControlPanel as BaseSiteControlPanel
from z3c.form.interfaces import HIDDEN_MODE
from Products.CMFPlone.controlpanel.browser.site import SiteControlPanel as BaseSiteControlPanel # noqa
from Products.CMFPlone.controlpanel.browser.site import SiteControlPanelForm as BaseSiteControlPanelForm # noqa


class SiteControlPanelForm(BaseSiteControlPanelForm):

def updateWidgets(self):
super(SiteControlPanelForm, self).updateWidgets()
# Hide the basic webstats_js field
self.widgets['webstats_js'].mode = HIDDEN_MODE


class SiteControlPanel(BaseSiteControlPanel):
"""
Hide the basic webstats_js field
"""

form_fields = FormFields(ISiteSchema).omit('webstats_js')

form = SiteControlPanelForm
14 changes: 14 additions & 0 deletions collective/analyticspanel/browser/site_p4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-

from zope.formlib.form import FormFields
from plone.app.controlpanel.site import ISiteSchema
from plone.app.controlpanel.site import SiteControlPanel as BaseSiteControlPanel


class SiteControlPanel(BaseSiteControlPanel):
"""
Hide the basic webstats_js field
"""

form_fields = FormFields(ISiteSchema).omit('webstats_js')

4 changes: 2 additions & 2 deletions docs/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Changelog
0.6.0 (unreleased)
------------------

- Plone 5 compatibility
[cekk]
- Plone 5 compatibility.
[cekk, mamico]


0.5.0 (2017-01-20)
Expand Down

0 comments on commit b64c62a

Please sign in to comment.