diff --git a/setup.py b/setup.py index 46556c9..296b598 100644 --- a/setup.py +++ b/setup.py @@ -67,6 +67,7 @@ "redturtle.bandi", "collective.volto.subsites", "redturtle.voltoplugin.editablefooter", + "collective.volto.subfooter", ], extras_require={ "test": [ diff --git a/src/iosanita/policy/profiles/default/metadata.xml b/src/iosanita/policy/profiles/default/metadata.xml index 38f1988..cc9d74b 100644 --- a/src/iosanita/policy/profiles/default/metadata.xml +++ b/src/iosanita/policy/profiles/default/metadata.xml @@ -14,5 +14,6 @@ profile-redturtle.bandi:default profile-collective.volto.subsites:default profile-redturtle.voltoplugin.editablefooter:default + profile-collective.volto.subfooter:default diff --git a/src/iosanita/policy/restapi/__init__.py b/src/iosanita/policy/restapi/__init__.py index e69de29..7835089 100644 --- a/src/iosanita/policy/restapi/__init__.py +++ b/src/iosanita/policy/restapi/__init__.py @@ -0,0 +1 @@ +JSON_FIELDS = ["search_sections", "quick_search_sections", "contatti_testata"] diff --git a/src/iosanita/policy/restapi/configure.zcml b/src/iosanita/policy/restapi/configure.zcml index e4b3d68..2d6e335 100644 --- a/src/iosanita/policy/restapi/configure.zcml +++ b/src/iosanita/policy/restapi/configure.zcml @@ -6,6 +6,7 @@ + + + diff --git a/src/iosanita/policy/restapi/services/iosanita_settings/__init__.py b/src/iosanita/policy/restapi/services/iosanita_settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/iosanita/policy/restapi/services/iosanita_settings/configure.zcml b/src/iosanita/policy/restapi/services/iosanita_settings/configure.zcml new file mode 100644 index 0000000..1e2d276 --- /dev/null +++ b/src/iosanita/policy/restapi/services/iosanita_settings/configure.zcml @@ -0,0 +1,26 @@ + + + + + + + + + diff --git a/src/iosanita/policy/restapi/services/iosanita_settings/get.py b/src/iosanita/policy/restapi/services/iosanita_settings/get.py new file mode 100644 index 0000000..8cae4d7 --- /dev/null +++ b/src/iosanita/policy/restapi/services/iosanita_settings/get.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +from plone.restapi.interfaces import IExpandableElement +from plone.restapi.services import Service +from zope.component import adapter +from iosanita.policy.interfaces import IIoSanitaSettings +from plone import api +from zope.interface import implementer +from zope.interface import Interface + +import json + + +@implementer(IExpandableElement) +@adapter(Interface, Interface) +class IoSanitaSettings(object): + def __init__(self, context, request): + self.context = context + self.request = request + + def __call__(self, expand=False): + """ + Bypass expand variable: it's always expanded because we always need this data. + """ + result = { + "iosanita-settings": { + "@id": f"{self.context.absolute_url()}/@iosanita-settings-data" + } + } + + contatti_testata = ( + api.portal.get_registry_record( + "contatti_testata", interface=IIoSanitaSettings + ) + or "" + ) + if contatti_testata: + contatti_testata = json.loads(contatti_testata) + else: + contatti_testata = None + result["iosanita-settings"]["contatti_testata"] = contatti_testata + + return result + + +class IoSanitaSettingsGet(Service): + def reply(self): + data = IoSanitaSettings(self.context, self.request) + return data()["iosanita-settings"] diff --git a/src/iosanita/policy/testing.py b/src/iosanita/policy/testing.py index afa6d4f..2b14465 100644 --- a/src/iosanita/policy/testing.py +++ b/src/iosanita/policy/testing.py @@ -15,6 +15,7 @@ import souper.plone import collective.volto.dropdownmenu import collective.volto.socialsettings +import collective.volto.subfooter class TestLayer(ContentTypesTestLayer): @@ -28,6 +29,7 @@ def setUpZope(self, app, configurationContext): self.loadZCML(package=collective.volto.slimheader) self.loadZCML(package=collective.volto.dropdownmenu) self.loadZCML(package=collective.volto.socialsettings) + self.loadZCML(package=collective.volto.subfooter) self.loadZCML(package=iosanita.policy, context=configurationContext) xmlconfig.file(