Skip to content

Commit

Permalink
Copy the controlpanel overview from plone.app.controlpanel [#290]
Browse files Browse the repository at this point in the history
  • Loading branch information
khink committed Nov 2, 2014
1 parent a3cf1c6 commit e335c7d
Show file tree
Hide file tree
Showing 4 changed files with 294 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Expand Up @@ -11,6 +11,10 @@ Changelog
- Adding the option to configure a bundle from the diazo manifest file.
[bloodbare]

- Move the controlpanel overview from plone.app.controlpanel into this package
https://github.com/plone/Products.CMFPlone/issues/290
[khink]


5.0a3 (2014-11-01)
------------------
Expand Down
8 changes: 8 additions & 0 deletions Products/CMFPlone/controlpanel/browser/configure.zcml
Expand Up @@ -9,6 +9,14 @@
<role name="Site Administrator"/>
</permission>

<!-- Control Panel Overview -->
<browser:page
name="overview-controlpanel"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".overview.OverviewControlPanel"
permission="plone.app.controlpanel.Overview"
/>

<!-- Editing Control Panel -->
<browser:page
name="editing-controlpanel"
Expand Down
170 changes: 170 additions & 0 deletions Products/CMFPlone/controlpanel/browser/overview.pt
@@ -0,0 +1,170 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="here/prefs_main_template/macros/master"
i18n:domain="plone">

<body>

<metal:override fill-slot="top_slot"
tal:define="disable_column_one python:request.set('disable_plone.leftcolumn',1);
disable_column_two python:request.set('disable_plone.rightcolumn',1);"/>

<div metal:fill-slot="prefs_configlet_main">

<h1 class="documentFirstHeading"
i18n:translate="">Site Setup</h1>

<p class="documentDescription" i18n:translate="description_control_panel">
Configuration area for Plone and add-on Products.
</p>

<div class="portalMessage warning"
tal:condition="view/upgrade_warning">
<strong i18n:translate="">
Warning
</strong>
<span tal:omit-tag="" i18n:translate="">
The site configuration is outdated and needs to be
upgraded. Please
<a href="#"
tal:attributes="href string:${context/portal_url}/@@plone-upgrade"
title="Go to the upgrade page"
i18n:attributes="title;"
i18n:name="link_continue_with_the_upgrade"
i18n:translate="">
continue with the upgrade
</a>.
</span>
</div>

<div class="portalMessage warning"
tal:condition="view/mailhost_warning">
<strong i18n:translate="">
Warning
</strong>
<span tal:omit-tag="" i18n:translate="text_no_mailhost_configured">
You have not configured a mail host or a site 'From'
address, various features including contact forms, email
notification and password reset will not work. Go to the
<tal:link i18n:name="label_mail_control_panel_link">
<a href=""
i18n:translate="text_no_mailhost_configured_control_panel_link"
tal:attributes="href string:${portal_url}/@@mail-controlpanel"
>Mail control panel</a>
</tal:link>
to fix this.
</span>
</div>

<div class="portalMessage warning"
tal:condition="view/timezone_warning">
<strong i18n:translate="">
Warning
</strong>
<span tal:omit-tag="" i18n:translate="text_no_timezone_configured">

You have not set the portal timezone. Date/Time handling will not
work properly for timezone aware date/time values.
Go to the
<tal:link i18n:name="label_mail_event_settings_link">
<a href=""
i18n:translate="text_no_timezone_configured_control_panel_link"
tal:attributes="href string:${portal_url}/@@dateandtime-controlpanel"
>Date and Time settings control panel</a>
</tal:link>
to fix this.
</span>
</div>

<div class="portalMessage warning"
tal:condition="not:view/pil">
<strong i18n:translate="">
Warning
</strong>
<span tal:omit-tag="" i18n:translate="text_no_pil_installed">
PIL is not installed properly, image scaling will not work.
</span>
</div>

<tal:category tal:repeat="category view/categories">

<section class="portlet portletNavigationTree portletSiteSetup" tal:define="sublist python:view.sublists(category.get('id'))">
<header class="portletHeader hiddenStructure" tal:content="category/title"
i18n:translate="">Category</header>

<nav class="portletContent" tal:condition="sublist">

<ul class="configlets"
tal:condition="sublist">
<tal:actions tal:repeat="action sublist">
<li tal:condition="action/visible">
<a href=""
tal:define="icon action/icon"
tal:attributes="href action/url">
<img src="" alt=""
tal:condition="not:icon"
tal:attributes="src string:${portal_url}/maintenance_icon.png" />
<img src="" alt=""
tal:condition="icon"
tal:attributes="src icon;
alt action/title;"
i18n:attributes="alt" />
<tal:title tal:content="action/title"
i18n:translate="">
Title
</tal:title>
</a>
</li>
</tal:actions>
</ul>
</nav>

<div class="discreet"
tal:condition="not:sublist"
i18n:translate="label_no_prefs_panels_available">
No preference panels available.
</div>

</section>

</tal:category>

<div class="visualClear"><!-- --></div>

<h2 i18n:translate="heading_version_overview">Version Overview</h2>
<ul>
<tal:list-versions repeat="version view/version_overview">
<li tal:content="version">Version</li>
</tal:list-versions>
</ul>

<p tal:condition="not:view/is_dev_mode"
class="discreet"
i18n:translate="description_production_mode">
You are running in "production mode". This is the preferred mode of
operation for a live Plone site, but means that some
configuration changes will not take effect until your server is
restarted or a product refreshed. If this is a development instance,
and you want to enable debug mode, stop the server, set 'debug-mode=on'
in your buildout.cfg, re-run bin/buildout and then restart the server
process.
</p>

<p tal:condition="view/is_dev_mode"
class="discreet"
i18n:translate="description_debug_mode">
You are running in "debug mode". This mode is intended for sites that
are under development. This allows many configuration changes to be
immediately visible, but will make your site run more slowly. To turn
off debug mode, stop the server, set 'debug-mode=off' in your
buildout.cfg, re-run bin/buildout and then restart the server
process.
</p>

</div>

</body>
</html>
112 changes: 112 additions & 0 deletions Products/CMFPlone/controlpanel/browser/overview.py
@@ -0,0 +1,112 @@
from AccessControl import getSecurityManager
from Acquisition import aq_base
from Acquisition import aq_inner
from Products.CMFCore.permissions import ManagePortal
from Products.CMFCore.utils import getToolByName
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from plone.app.controlpanel.form import ControlPanelView
from plone.memoize.instance import memoize
from plone.registry.interfaces import IRegistry
from zope.component import getUtility

try:
import plone.app.event # nopep8
HAS_PAE = True
except ImportError:
HAS_PAE = False


class OverviewControlPanel(ControlPanelView):

template = ViewPageTemplateFile('overview.pt')

base_category = 'controlpanel'
ignored_categories = ('controlpanel_user')

def __call__(self):
self.request.set('disable_border', 1)
return self.template()

@memoize
def cptool(self):
return getToolByName(aq_inner(self.context), 'portal_controlpanel')

@memoize
def migration(self):
return getToolByName(aq_inner(self.context), 'portal_migration')

@memoize
def core_versions(self):
return self.migration().coreVersions()

def pil(self):
return 'PIL' in self.core_versions()

def version_overview(self):

core_versions = self.core_versions()
versions = [
'Plone %s (%s)' % (core_versions['Plone'],
core_versions['Plone Instance'])]

for v in ('CMF', 'Zope', 'Python'):
versions.append(v + ' ' + core_versions.get(v))
pil = core_versions.get('PIL', None)
if pil is not None:
versions.append('PIL ' + pil)
return versions

@memoize
def is_dev_mode(self):
qi = getToolByName(aq_inner(self.context), 'portal_quickinstaller')
return qi.isDevelopmentMode()

def upgrade_warning(self):
mt = getToolByName(aq_inner(self.context), 'portal_migration')
if mt.needUpgrading():
# if the user can't run the upgrade, no sense in displaying the
# message
sm = getSecurityManager()
if sm.checkPermission(ManagePortal, self.context):
return True
return False

def mailhost_warning(self):
mailhost = getToolByName(aq_inner(self.context), 'MailHost', None)
if mailhost is None:
return True
mailhost = getattr(aq_base(mailhost), 'smtp_host', None)
email = getattr(aq_inner(self.context), 'email_from_address', None)
if mailhost and email:
return False
return True

def timezone_warning(self):
"""Returns true, if the portal_timezone is not set in the registry.
"""
if not HAS_PAE:
# No point of having a portal timezone configured without
# plone.app.event installed.
# TODO: Above applies to situation at time of writing. If other
# datetimes outside plone.app.event use proper timezones too, the
# HAS_PAE should be removed.
return False
# check if 'plone.portal_timezone' is in registry
registry = getUtility(IRegistry)
reg_key = "plone.portal_timezone"
if reg_key not in registry:
# else use 'plone.app.event.portal_timezone'
# < Plone 5
reg_key = 'plone.app.event.portal_timezone'
if reg_key not in registry:
return True
portal_timezone = registry[reg_key]
if portal_timezone:
return False
return True # No portal_timezone found.

def categories(self):
return self.cptool().getGroups()

def sublists(self, category):
return self.cptool().enumConfiglets(group=category)

0 comments on commit e335c7d

Please sign in to comment.