Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Us 52023 controlpanel asl #2

Merged
merged 5 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
21 changes: 21 additions & 0 deletions src/iosanita/policy/browser/configure.zcml
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>
12 changes: 12 additions & 0 deletions src/iosanita/policy/browser/controlpanel.py
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
1 change: 1 addition & 0 deletions src/iosanita/policy/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
-->
<!--<includeDependencies package="." />-->

<include package=".browser" />
<include package=".restapi" />


Expand Down
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 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,
)
20 changes: 20 additions & 0 deletions src/iosanita/policy/profiles/default/controlpanel.xml
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 src/iosanita/policy/profiles/default/registry/settings.xml
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>
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>
16 changes: 16 additions & 0 deletions src/iosanita/policy/restapi/controlpanel.py
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
2 changes: 1 addition & 1 deletion src/iosanita/policy/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import collective.volto.slimheader
import iosanita.contenttypes
import iosanita.policy
import souper.plone
import plone.app.caching
import souper.plone


class TestLayer(ContentTypesTestLayer):
Expand Down
39 changes: 39 additions & 0 deletions src/iosanita/policy/tests/test_controlpanel_api.py
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)
31 changes: 1 addition & 30 deletions test_plone60.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -131,33 +131,4 @@ souper.plone = 1.3.1
# iosanita.contenttypes==2.0.0.dev0
# iosanita.policy==1.0.0.dev0
# redturtle.volto==5.5.0
z3c.jbot = 2.0

# Added by buildout at 2024-08-14 17:13:10.027495

# Required by:
# iosanita.policy==1.0.0.dev0
collective.volto.slimheader = 1.0.1

# Required by:
# iosanita.policy==1.0.0.dev0
iw.rejectanonymous = 1.2.7

# Added by buildout at 2024-08-14 17:14:55.049853
plone.formwidget.autocomplete = 1.4.1

# Required by:
# redturtle.bandi==1.4.5
collective.tiles.collection = 2.0.0

# Required by:
# collective.tiles.collection==2.0.0
plone.app.tiles = 4.0.1

# Required by:
# collective.tiles.collection==2.0.0
plone.formwidget.contenttree = 1.2.0

# Required by:
# iosanita.contenttypes==2.0.0.dev0
redturtle.bandi = 1.4.5
z3c.jbot = 2.0
Loading