-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added controlpanel settings * zpretty * refactored controlpanel * code cleanup --------- Co-authored-by: Andrea Cecchi <[email protected]>
- Loading branch information
1 parent
94729eb
commit 1d89311
Showing
12 changed files
with
217 additions
and
38 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:browser="http://namespaces.zope.org/browser" | ||
xmlns:plone="http://namespaces.plone.org/plone" | ||
i18n_domain="iosanita.policy" | ||
> | ||
|
||
<include | ||
package="z3c.jbot" | ||
file="meta.zcml" | ||
/> | ||
|
||
<browser:page | ||
name="iosanita-settings" | ||
for="Products.CMFPlone.interfaces.IPloneSiteRoot" | ||
class=".controlpanel.IoSanitaControlPanel" | ||
permission="cmf.ManagePortal" | ||
layer="iosanita.policy.interfaces.IIosanitaPolicyLayer" | ||
/> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from iosanita.policy import _ | ||
from iosanita.policy.interfaces import IIoSanitaSettings | ||
from plone.app.registry.browser import controlpanel | ||
|
||
|
||
class IoSanitaSettingsForm(controlpanel.RegistryEditForm): | ||
schema = IIoSanitaSettings | ||
label = _("iosanita_settings_label", default="Io-Sanità Settings") | ||
|
||
|
||
class IoSanitaControlPanel(controlpanel.ControlPanelFormWrapper): | ||
form = IoSanitaSettingsForm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,88 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Module where all interfaces, events and exceptions live.""" | ||
|
||
from iosanita.policy import _ | ||
from plone.restapi.controlpanels.interfaces import IControlpanel | ||
from zope.interface import Interface | ||
from zope.publisher.interfaces.browser import IDefaultBrowserLayer | ||
from zope.schema import Bool | ||
from zope.schema import List | ||
from zope.schema import SourceText | ||
from zope.schema import TextLine | ||
|
||
|
||
class IIosanitaPolicyLayer(IDefaultBrowserLayer): | ||
"""Marker interface that defines a browser layer.""" | ||
|
||
|
||
class IIoSanitaSettingsControlpanel(IControlpanel): | ||
""" """ | ||
|
||
|
||
class IIoSanitaSettings(Interface): | ||
""" | ||
Control panel settings | ||
""" | ||
|
||
lead_image_dimension = List( | ||
title=_( | ||
"lead_image_dimension_label", | ||
default="Dimensioni lead image", | ||
), | ||
description=_( | ||
"lead_image_dimension_help", | ||
default="Se un content-type deve avere una dimensione della " | ||
"leadimage particolare, indicarle qui. " | ||
"Inserire le dimensioni nella forma di esempio " | ||
"PortalType|900x900", | ||
), | ||
required=True, | ||
default=[ | ||
"News Item|1920x600", | ||
"Servizio|1920x600", | ||
"UnitaOrganizzativa|1920x600", | ||
"Persona|180x100", | ||
], | ||
value_type=TextLine(), | ||
) | ||
|
||
search_sections = SourceText( | ||
title=_("search_sections_label", default="Sezioni ricerca"), | ||
description=_( | ||
"search_sections_help", | ||
default="Inserire una lista di sezioni per la ricerca.", | ||
), | ||
default="", | ||
required=False, | ||
) | ||
|
||
show_modified_default = Bool( | ||
title=_("show_modified_default_label", default="Mostra la data di modifica"), | ||
description=_( | ||
"show_modified_default_help", | ||
default="Questo è il valore di default per decidere se mostrare " | ||
"o meno la data di modifica nei contenuti che hanno la behavior " | ||
"abilitata. E' poi possibile sovrascrivere il default nei singoli " | ||
'contenuti (nel tab "Impostazioni").', | ||
), | ||
default=True, | ||
required=False, | ||
) | ||
|
||
show_dynamic_folders_in_footer = Bool( | ||
title=_("show_dynamic_folders_in_footer_label", default="Footer dinamico"), | ||
description=_( | ||
"show_dynamic_folders_in_footer_help", | ||
default="Se selezionato, il footer verrà popolato automaticamente " | ||
"con i contenuti di primo livello non esclusi dalla navigazione.", | ||
), | ||
default=True, | ||
required=False, | ||
) | ||
|
||
contatti_testata = SourceText( | ||
title=_("contatti_testata_label", default="Contatti in testata"), | ||
description=_( | ||
"contatti_testatas_help", | ||
default="Inserire i contatti.", | ||
), | ||
default="", | ||
required=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n" | ||
name="portal_controlpanel" | ||
i18n:domain="iosanita.policy" | ||
> | ||
|
||
<configlet action_id="IoSanitaSettings" | ||
appId="IoSanitaSettings" | ||
category="Products" | ||
condition_expr="" | ||
icon_expr="" | ||
title="Impostazioni IoSanita" | ||
url_expr="string:${portal_url}/@@iosanita-settings" | ||
visible="True" | ||
i18n:attributes="title" | ||
> | ||
<permission>Manage portal</permission> | ||
</configlet> | ||
|
||
</object> |
16 changes: 16 additions & 0 deletions
16
src/iosanita/policy/profiles/default/registry/settings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<registry xmlns:i18n="http://xml.zope.org/namespaces/i18n" | ||
i18n:domain="plone" | ||
> | ||
<records interface="iosanita.policy.interfaces.IIoSanitaSettings" /> | ||
|
||
<!-- custom values --> | ||
<record field="allowed_sizes" | ||
interface="Products.CMFPlone.interfaces.controlpanel.IImagingSchema" | ||
name="plone.allowed_sizes" | ||
> | ||
<value purge="False"> | ||
<element>gallery 250:65536</element> | ||
</value> | ||
</record> | ||
</registry> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from iosanita.policy.interfaces import IIosanitaPolicyLayer | ||
from iosanita.policy.interfaces import IIoSanitaSettings | ||
from iosanita.policy.interfaces import IIoSanitaSettingsControlpanel | ||
from plone.restapi.controlpanels import RegistryConfigletPanel | ||
from zope.component import adapter | ||
from zope.interface import implementer | ||
from zope.interface import Interface | ||
|
||
|
||
@adapter(Interface, IIosanitaPolicyLayer) | ||
@implementer(IIoSanitaSettingsControlpanel) | ||
class IoSanitaSettingsControlpanel(RegistryConfigletPanel): | ||
schema = IIoSanitaSettings | ||
configlet_id = "IoSanitaSettings" | ||
configlet_category_id = "Products" | ||
schema_prefix = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
from iosanita.policy.testing import RESTAPI_TESTING | ||
from plone.app.testing import setRoles | ||
from plone.app.testing import SITE_OWNER_NAME | ||
from plone.app.testing import SITE_OWNER_PASSWORD | ||
from plone.app.testing import TEST_USER_ID | ||
from plone.restapi.testing import RelativeSession | ||
|
||
import unittest | ||
|
||
|
||
class ControlpanelTest(unittest.TestCase): | ||
layer = RESTAPI_TESTING | ||
|
||
def setUp(self): | ||
self.app = self.layer["app"] | ||
self.portal = self.layer["portal"] | ||
self.portal_url = self.portal.absolute_url() | ||
|
||
self.api_session = RelativeSession(self.portal_url) | ||
self.api_session.headers.update({"Accept": "application/json"}) | ||
self.api_session.auth = (SITE_OWNER_NAME, SITE_OWNER_PASSWORD) | ||
|
||
setRoles(self.portal, TEST_USER_ID, ["Manager"]) | ||
|
||
def test_controlpanel_exists(self): | ||
response = self.api_session.get("/@controlpanels/iosanita-settings") | ||
|
||
import pdb | ||
|
||
pdb.set_trace() | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.headers.get("Content-Type"), "application/json") | ||
|
||
def test_controlpanel_listed(self): | ||
response = self.api_session.get("/@controlpanels") | ||
|
||
titles = [x.get("title") for x in response.json()] | ||
self.assertIn("Impostazioni IoSanita", titles) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters