Skip to content

Commit

Permalink
Merge pull request #16 from plone/bootstrap-zmi
Browse files Browse the repository at this point in the history
optimize for new bootstrap based ZMI
  • Loading branch information
jensens authored Oct 3, 2018
2 parents 298464f + 7b57cc3 commit cda0dbe
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 55 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ New features:

Bug fixes:

- make registrations.html look good in Bootstrap-ZMI,
still working fine in old ZMI.
[jensens]

- Fix templateViewRegistrationGroups and tests in py3.
[pbauer]

Expand Down
7 changes: 1 addition & 6 deletions plone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
# -*- coding: utf-8 -*-
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__)
7 changes: 1 addition & 6 deletions plone/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
# -*- coding: utf-8 -*-
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
__import__('pkg_resources').declare_namespace(__name__)
2 changes: 1 addition & 1 deletion plone/app/customerize/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from five.customerize.interfaces import IViewTemplateContainer
from five.customerize.utils import findViewletTemplate
from five.customerize.zpt import TTWViewTemplate
from operator import itemgetter
from os.path import basename
from plone.browserlayer.interfaces import ILocalBrowserLayerType
from plone.portlets.interfaces import IPortletRenderer
Expand All @@ -13,7 +14,6 @@
from zope.component import getUtility
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.viewlet.interfaces import IViewlet
from operator import itemgetter


def getViews(type):
Expand Down
66 changes: 29 additions & 37 deletions plone/app/customerize/registrations.pt
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
<h1 tal:replace="structure context/manage_page_header" />
<h1 tal:replace="structure context/manage_tabs" />

<style type="text/css">
dl {
font-family: Verdana, Helvetica, sans-serif;
font-size: 10pt;
margin-left: 1em;
}
dd {
margin-bottom: 1em;
}
dd span.type {
color: #999;
}
.customized {
background-color: yellow;
}
</style>
<main class="container-fluid">

<div>
<p>The following list shows all registered (template-based) views
sorted by interface. Click one of the links to see the contents
of the view template and possibly customize it. Views that already
have been customized are <span class="customized">highlighted like
this</span>.</p>
</div>
<style type="text/css">
dd span.type {
color: #999;
}
.customized {
background-color: yellow;
}
</style>

<div>
<p>ATTENTION: beware using this tool. Errors (e.g. <code>TypeError</code>,
<code>Unauthorized</code> etc) may popup if some kinds of
<code>python:</code> expressions are used in the template, making it
impossible to customize here (try z3c.jbot or regular zcml overrides
instead). The reason is that browser view templates are Zope 3 templates
while items in portal_view_customization are Zope 2 templates. The different
security models underlying the two implementations may break rendering of the
site. If that happens just delete the custom copy using the Contents tab
above.</p>
<div class="alert alert-danger" role="alert">
ATTENTION: beware using this tool.
Errors (e.g. <code>TypeError</code>, <code>Unauthorized</code> etc) may popup if some kinds of
<code>python:</code> expressions are used in the template.
This makes it impossible to customize those here (try z3c.jbot or regular zcml overrides instead).
The reason is that browser view templates are Chameleon Pagetemplates while items in portal_view_customization are Zope 2 templates.
The different security models underlying the two implementations may break rendering of thesite.
If that happens just delete the custom copy using the Contents tab above.
</div>

<div>
<p class="form-help">
The following list shows all registered (template-based) views
sorted by interface. Click one of the links to see the contents
of the view template and possibly customize it. Views that already
have been customized are <span class="customized">highlighted like
this</span>.
</p>

<article tal:repeat="iface python:view.getTemplateViewRegistrations(mangle=False)">
<header tal:content="iface/name" />
<ul>
Expand All @@ -54,10 +45,11 @@
title info/zptfile;"
tal:content="info/viewname">
</a>
<span tal:content="string:(${info/type})" class="type" /> <br />
<code tal:content="string:(${info/type})" class="type" /> <br />
</li>
</ul>
</article>
</div>

<h1 tal:replace="structure context/manage_page_footer" />
</main>

<h1 tal:replace="structure context/manage_page_footer" />
8 changes: 5 additions & 3 deletions plone/app/customerize/tests/testDocTests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from plone.app.customerize.testing import PLONE_APP_CUSTOMERIZE_FUNCTIONAL_TESTING # noqa
from plone.app.customerize.testing import (
PLONE_APP_CUSTOMERIZE_FUNCTIONAL_TESTING # noqa
)
from plone.testing import layered
from unittest import TestSuite

Expand All @@ -18,7 +20,7 @@ def check_output(self, want, got, optionflags):

def test_suite():
suite = TestSuite()
OPTIONFLAGS = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
OPTIONFLAGS = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
for testfile in ('testBrowserLayers.txt', 'testCustomizeView.txt'):
suite.addTest(
layered(
Expand All @@ -28,7 +30,7 @@ def test_suite():
package='plone.app.customerize.tests',
checker=Py23DocChecker(),
),
layer=PLONE_APP_CUSTOMERIZE_FUNCTIONAL_TESTING
layer=PLONE_APP_CUSTOMERIZE_FUNCTIONAL_TESTING,
)
)
return suite
7 changes: 5 additions & 2 deletions plone/app/customerize/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ class ViewTemplateContainer(Folder):
security = ClassSecurityInfo()

manage_options = (
dict(label='Registrations', action='registrations.html'),
) + Folder.manage_options[0:1] + Folder.manage_options[2:]
(dict(label='Registrations', action='registrations.html'),) +
Folder.manage_options[0:1] +
Folder.manage_options[2:]
)

@security.protected(ManagePortal)
def addTemplate(self, id, template):
""" add the given ttw view template to the container """
self._setObject(id, template)
return getattr(self, id)


InitializeClass(ViewTemplateContainer)

1 comment on commit cda0dbe

@jenkins-plone-org
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jensens Jenkins CI reporting about code analysis
See the full report here: https://jenkins.plone.org/job/package-plone.app.customerize/30/violations

plone/app/customerize/registration.py:49:15: P002 found "hasattr", consider replacing it
plone/app/customerize/registration.py:51:11: T000 Todo note found.
plone/app/customerize/registration.py:74:15: T000 Todo note found.
plone/app/customerize/registration.py:112:35: C812 missing trailing comma
plone/app/customerize/registration.py:135:31: C812 missing trailing comma
plone/app/customerize/registration.py:155:7: T000 Todo note found.
plone/app/customerize/testing.py:13:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/app/customerize/testing.py:16:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/app/customerize/testing.py:19:9: D001 found xmlconfig.file( replace it with self.loadZCML(
plone/app/customerize/tests/testDocTests.py:2:1: I001 isort found an import in the wrong position
plone/app/customerize/tests/testDocTests.py:4:1: I001 isort found an import in the wrong position
plone/app/customerize/tests/testDocTests.py:34:14: C812 missing trailing comma

Follow these instructions to reproduce it locally.

Please sign in to comment.