Skip to content

Commit

Permalink
refactored controlpanel
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Aug 14, 2024
1 parent 1b610c8 commit c077e2e
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 140 deletions.
3 changes: 2 additions & 1 deletion src/iosanita/policy/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
<browser:page
name="iosanita-settings"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".controlpanel.IoSanitaSettingsView"
class=".controlpanel.IoSanitaControlPanel"
permission="cmf.ManagePortal"
layer="iosanita.policy.interfaces.IIosanitaPolicyLayer"
/>

</configure>
15 changes: 5 additions & 10 deletions src/iosanita/policy/browser/controlpanel.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# -*- coding: utf-8 -*-
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
from plone.app.registry.browser.controlpanel import RegistryEditForm
from iosanita.policy import _
from iosanita.policy.controlpanels.settings import IIoSanitaSettings
from iosanita.policy.interfaces import IIoSanitaSettings
from plone.app.registry.browser import controlpanel


class IoSanitaSettingsForm(RegistryEditForm):
class IoSanitaSettingsForm(controlpanel.RegistryEditForm):
schema = IIoSanitaSettings
id = "iosanita-settings"
label = _("IoSanita Settings")
label = _("iosanita_settings_label", default="Io-Sanità Settings")


class IoSanitaSettingsView(ControlPanelFormWrapper):
""" """

class IoSanitaControlPanel(controlpanel.ControlPanelFormWrapper):
form = IoSanitaSettingsForm
Empty file.
94 changes: 0 additions & 94 deletions src/iosanita/policy/controlpanels/settings.py

This file was deleted.

86 changes: 83 additions & 3 deletions src/iosanita/policy/interfaces.py
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 zope.publisher.interfaces.browser import IDefaultBrowserLayer
from iosanita.policy import _
from plone.restapi.controlpanels.interfaces import IControlpanel
from zope.interface import Interface
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,
)
4 changes: 2 additions & 2 deletions src/iosanita/policy/profiles/default/controlpanel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
>

<configlet action_id="IoSanitaSettings"
appId="iosanita.settings"
appId="IoSanitaSettings"
category="Products"
condition_expr=""
icon_expr=""
Expand All @@ -17,4 +17,4 @@
<permission>Manage portal</permission>
</configlet>

</object>
</object>
2 changes: 1 addition & 1 deletion src/iosanita/policy/profiles/default/registry/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<registry xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="plone"
>
<records interface="iosanita.policy.controlpanels.settings.IIoSanitaSettings" />
<records interface="iosanita.policy.interfaces.IIoSanitaSettings" />

<!-- custom values -->
<record field="allowed_sizes"
Expand Down
11 changes: 7 additions & 4 deletions src/iosanita/policy/restapi/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
xmlns:plone="http://namespaces.plone.org/plone"
>

<include
package="plone.restapi"
file="configure.zcml"
/>
<include package="plone.restapi"/>
<include package=".services" />

<!-- enable controlpanel on plone.restapi -->
<adapter
factory=".controlpanel.IoSanitaSettingsControlpanel"
provides="iosanita.policy.interfaces.IIoSanitaSettingsControlpanel"
name="iosanita-settings"
/>
</configure>
6 changes: 0 additions & 6 deletions src/iosanita/policy/restapi/services/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,4 @@

<include package=".search_tassonomie" />

<adapter
factory=".controlpanel.IoSanitaSettings"
provides="iosanita.policy.controlpanels.settings.IIoSanitaSettings"
name="iosanita-settings"
/>

</configure>
18 changes: 0 additions & 18 deletions src/iosanita/policy/restapi/services/controlpanel.py

This file was deleted.

5 changes: 4 additions & 1 deletion src/iosanita/policy/tests/test_controlpanel_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ def setUp(self):
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("IoSanita Settings", titles)
self.assertIn("Impostazioni IoSanita", titles)

0 comments on commit c077e2e

Please sign in to comment.