diff --git a/src/iosanita/contenttypes/adapters/query.py b/src/iosanita/contenttypes/adapters/query.py index 25be442..4b76b3f 100644 --- a/src/iosanita/contenttypes/adapters/query.py +++ b/src/iosanita/contenttypes/adapters/query.py @@ -1,10 +1,10 @@ from iosanita.contenttypes.interfaces import IIosanitaContenttypesLayer +from plone import api from plone.restapi.interfaces import IZCatalogCompatibleQuery from plone.restapi.search.query import ZCatalogCompatibleQueryAdapter as BaseAdapter from zope.component import adapter from zope.interface import implementer from zope.interface import Interface -from plone import api @implementer(IZCatalogCompatibleQuery) diff --git a/src/iosanita/contenttypes/behaviors/a_chi_si_rivolge.py b/src/iosanita/contenttypes/behaviors/a_chi_si_rivolge.py index c7484c9..d3eac31 100644 --- a/src/iosanita/contenttypes/behaviors/a_chi_si_rivolge.py +++ b/src/iosanita/contenttypes/behaviors/a_chi_si_rivolge.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from collective.volto.blocksfield.field import BlocksField from iosanita.contenttypes import _ from plone.autoform.interfaces import IFormFieldProvider from plone.dexterity.interfaces import IDexterityContent @@ -7,7 +8,6 @@ from zope.component import adapter from zope.interface import implementer from zope.interface import provider -from collective.volto.blocksfield.field import BlocksField @provider(IFormFieldProvider) diff --git a/src/iosanita/contenttypes/behaviors/configure.zcml b/src/iosanita/contenttypes/behaviors/configure.zcml index df6b7af..c805235 100644 --- a/src/iosanita/contenttypes/behaviors/configure.zcml +++ b/src/iosanita/contenttypes/behaviors/configure.zcml @@ -45,7 +45,7 @@ provides=".contatti.IContatti" marker=".contatti.IContatti" /> - - - - - + diff --git a/src/iosanita/contenttypes/behaviors/contatti.py b/src/iosanita/contenttypes/behaviors/contatti.py index fc081a8..d4e4f91 100644 --- a/src/iosanita/contenttypes/behaviors/contatti.py +++ b/src/iosanita/contenttypes/behaviors/contatti.py @@ -1,21 +1,19 @@ # -*- coding: utf-8 -*- +from collective.volto.blocksfield.field import BlocksField +from iosanita.contenttypes import _ +from iosanita.contenttypes.interfaces.persona import IPersona +from iosanita.contenttypes.interfaces.unita_organizzativa import IUnitaOrganizzativa +from plone.app.dexterity import textindexer from plone.app.z3cform.widget import RelatedItemsFieldWidget from plone.autoform import directives as form from plone.autoform.interfaces import IFormFieldProvider +from plone.dexterity.interfaces import IDexterityContent from plone.supermodel import model from z3c.relationfield.schema import RelationChoice from z3c.relationfield.schema import RelationList from zope.component import adapter from zope.interface import implementer from zope.interface import provider -from plone.app.dexterity import textindexer -from collective.volto.blocksfield.field import BlocksField -from plone.dexterity.interfaces import IDexterityContent - -from iosanita.contenttypes import _ -from iosanita.contenttypes.interfaces.persona import IPersona - -from iosanita.contenttypes.interfaces.unita_organizzativa import IUnitaOrganizzativa class IContattiSchema(model.Schema): diff --git a/src/iosanita/contenttypes/behaviors/dove.py b/src/iosanita/contenttypes/behaviors/dove.py index f77906d..934eef9 100644 --- a/src/iosanita/contenttypes/behaviors/dove.py +++ b/src/iosanita/contenttypes/behaviors/dove.py @@ -1,17 +1,16 @@ # -*- coding: utf-8 -*- from collective.address.behaviors import IAddress +from collective.geolocationbehavior.geolocation import IGeolocatable from iosanita.contenttypes import _ from plone.app.dexterity import textindexer +from plone.autoform.interfaces import IFormFieldProvider from plone.dexterity.interfaces import IDexterityContent from plone.supermodel import model +from z3c.relationfield.schema import RelationChoice +from z3c.relationfield.schema import RelationList from zope import schema from zope.component import adapter from zope.interface import implementer -from z3c.relationfield.schema import RelationChoice, RelationList -from collective.geolocationbehavior.geolocation import IGeolocatable -from z3c.relationfield.schema import RelationChoice -from z3c.relationfield.schema import RelationList -from plone.autoform.interfaces import IFormFieldProvider from zope.interface import provider diff --git a/src/iosanita/contenttypes/behaviors/ulteriori_informazioni.py b/src/iosanita/contenttypes/behaviors/ulteriori_informazioni.py index 88b8752..9fd5d62 100644 --- a/src/iosanita/contenttypes/behaviors/ulteriori_informazioni.py +++ b/src/iosanita/contenttypes/behaviors/ulteriori_informazioni.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from iosanita.contenttypes import _ from collective.volto.blocksfield.field import BlocksField +from iosanita.contenttypes import _ from plone.app.dexterity import textindexer from plone.autoform.interfaces import IFormFieldProvider from plone.dexterity.interfaces import IDexterityContent diff --git a/src/iosanita/contenttypes/controlpanels/settings.py b/src/iosanita/contenttypes/controlpanels/settings.py index 7b36b74..72bd193 100644 --- a/src/iosanita/contenttypes/controlpanels/settings.py +++ b/src/iosanita/contenttypes/controlpanels/settings.py @@ -15,7 +15,6 @@ class IoSanitaSettingsControlpanel(IControlpanel): class IIoSanitaSettings(Interface): - lead_image_dimension = List( title=_( "lead_image_dimension_label", diff --git a/src/iosanita/contenttypes/events/events.py b/src/iosanita/contenttypes/events/events.py index 1afaab7..612ba00 100644 --- a/src/iosanita/contenttypes/events/events.py +++ b/src/iosanita/contenttypes/events/events.py @@ -1,4 +1,5 @@ -from Acquisition import aq_inner, aq_parent +from Acquisition import aq_inner +from Acquisition import aq_parent def EventModified(dx_event, event): diff --git a/src/iosanita/contenttypes/interfaces/step.py b/src/iosanita/contenttypes/interfaces/step.py index 04cb4a8..1778b8a 100644 --- a/src/iosanita/contenttypes/interfaces/step.py +++ b/src/iosanita/contenttypes/interfaces/step.py @@ -2,11 +2,11 @@ from collective.volto.blocksfield.field import BlocksField from iosanita.contenttypes import _ from iosanita.contenttypes.interfaces import IIosanitaContenttypes +from plone.app.z3cform.widget import RelatedItemsFieldWidget +from plone.autoform import directives as form from plone.supermodel import model from z3c.relationfield.schema import RelationChoice from z3c.relationfield.schema import RelationList -from plone.app.z3cform.widget import RelatedItemsFieldWidget -from plone.autoform import directives as form class IStep(model.Schema, IIosanitaContenttypes): diff --git a/src/iosanita/contenttypes/interfaces/struttura.py b/src/iosanita/contenttypes/interfaces/struttura.py index c02e0a6..d22b35f 100644 --- a/src/iosanita/contenttypes/interfaces/struttura.py +++ b/src/iosanita/contenttypes/interfaces/struttura.py @@ -1,17 +1,15 @@ # -*- coding: utf-8 -*- +from collective.volto.blocksfield.field import BlocksField from iosanita.contenttypes import _ from iosanita.contenttypes.interfaces import IIosanitaContenttypes - +from plone.app.dexterity import textindexer from plone.app.z3cform.widget import RelatedItemsFieldWidget from plone.autoform import directives as form from plone.supermodel import model - from z3c.relationfield.schema import RelationChoice from z3c.relationfield.schema import RelationList from zope import schema -from collective.volto.blocksfield.field import BlocksField -from plone.app.dexterity import textindexer class IStruttura(model.Schema, IIosanitaContenttypes): diff --git a/src/iosanita/contenttypes/interfaces/unita_organizzativa.py b/src/iosanita/contenttypes/interfaces/unita_organizzativa.py index 2000972..b48d3fe 100644 --- a/src/iosanita/contenttypes/interfaces/unita_organizzativa.py +++ b/src/iosanita/contenttypes/interfaces/unita_organizzativa.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from collective.volto.blocksfield.field import BlocksField +from iosanita.contenttypes import _ from plone.app.dexterity import textindexer from plone.app.z3cform.widget import RelatedItemsFieldWidget from plone.autoform import directives as form @@ -9,9 +10,6 @@ from zope import schema -from iosanita.contenttypes import _ - - # TODO: migration script for these commented fields towards PDC # contact_info # Probabilmente non possibile trattandosi di un campo a blocchi diff --git a/src/iosanita/contenttypes/restapi/serializers/persona.py b/src/iosanita/contenttypes/restapi/serializers/persona.py index fe67278..24e8157 100644 --- a/src/iosanita/contenttypes/restapi/serializers/persona.py +++ b/src/iosanita/contenttypes/restapi/serializers/persona.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- -#from .related_news_serializer import SerializeFolderToJson +# from .related_news_serializer import SerializeFolderToJson from Acquisition import aq_inner from iosanita.contenttypes.interfaces.persona import IPersona from plone.restapi.interfaces import ISerializeToJson from plone.restapi.interfaces import ISerializeToJsonSummary from plone.restapi.serializer.dxcontent import SerializeToJson - from zc.relation.interfaces import ICatalog from zope.component import adapter from zope.component import getMultiAdapter @@ -43,7 +42,6 @@ def related_contents(self, field): items.append(summary) return sorted(items, key=lambda k: k["title"]) - def get_structure_backreferences(self, ct_type): catalog = getUtility(ICatalog) intids = getUtility(IIntIds) @@ -56,16 +54,18 @@ def get_structure_backreferences(self, ct_type): for i in backreferences if i.portal_type == ct_type ] - + def __call__(self, version=None, include_items=True): result = super(PersonaSerializer, self).__call__( version=version, include_items=include_items ) - + if getattr(self.context, "incarichi", ""): result["ruolo"] = getattr(self.context, "incarichi").raw - - result["organizzazione_riferimento"] = self.get_service_backreferences("UnitaOrganizzativa") + + result["organizzazione_riferimento"] = self.get_service_backreferences( + "UnitaOrganizzativa" + ) result["strutture_in_cui_opera"] = self.get_service_backreferences("Struttura") return result diff --git a/src/iosanita/contenttypes/restapi/serializers/unita_organizzativa.py b/src/iosanita/contenttypes/restapi/serializers/unita_organizzativa.py index 6290eeb..1474ab1 100644 --- a/src/iosanita/contenttypes/restapi/serializers/unita_organizzativa.py +++ b/src/iosanita/contenttypes/restapi/serializers/unita_organizzativa.py @@ -1,9 +1,12 @@ # -*- coding: utf-8 -*- from Acquisition import aq_inner +from iosanita.contenttypes.interfaces.unita_organizzativa import IUnitaOrganizzativa from plone import api from plone.restapi.interfaces import ISerializeToJson from plone.restapi.interfaces import ISerializeToJsonSummary from plone.restapi.serializer.converters import json_compatible +from plone.restapi.serializer.dxcontent import SerializeToJson +from plone.restapi.serializer.summary import DefaultJSONSummarySerializer from zc.relation.interfaces import ICatalog from zope.component import adapter from zope.component import getMultiAdapter @@ -11,12 +14,8 @@ from zope.globalrequest import getRequest from zope.interface import implementer from zope.interface import Interface -from zope.security import checkPermission -from plone.restapi.serializer.dxcontent import SerializeToJson -from plone.restapi.serializer.summary import DefaultJSONSummarySerializer from zope.intid.interfaces import IIntIds - -from iosanita.contenttypes.interfaces.unita_organizzativa import IUnitaOrganizzativa +from zope.security import checkPermission @implementer(ISerializeToJson) @@ -137,7 +136,6 @@ def __call__(self, force_images=True, **kwargs): ] for field in fields: - if field in ("contact_info", "sede"): data[field] = json_compatible(getattr(self.context, field, "")) diff --git a/src/iosanita/contenttypes/setuphandlers.py b/src/iosanita/contenttypes/setuphandlers.py index 36073a9..6f03334 100644 --- a/src/iosanita/contenttypes/setuphandlers.py +++ b/src/iosanita/contenttypes/setuphandlers.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- -from Products.CMFPlone.interfaces import INonInstallable from collective.taxonomy.interfaces import ITaxonomy +from plone import api +from Products.CMFPlone.interfaces import INonInstallable from zope.component import getUtilitiesFor from zope.interface import implementer -from plone import api import logging + logger = logging.getLogger(__name__) DEFAULT_PROFILE = "profile-iosanita.contenttypes:default" @@ -72,7 +73,6 @@ def post_install(context): def post_install_taxonomy(context): - try: for index in [ "tipologia_notizia", diff --git a/src/iosanita/contenttypes/testing.py b/src/iosanita/contenttypes/testing.py index e2a40b6..5b615e0 100644 --- a/src/iosanita/contenttypes/testing.py +++ b/src/iosanita/contenttypes/testing.py @@ -1,26 +1,25 @@ +from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE from plone.app.testing import applyProfile from plone.app.testing import FunctionalTesting from plone.app.testing import IntegrationTesting from plone.app.testing import PLONE_FIXTURE from plone.app.testing import PloneSandboxLayer from plone.testing.zope import WSGI_SERVER_FIXTURE -from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE +from redturtle.volto.testing import RedturtleVoltoLayer from zope.configuration import xmlconfig -import plone.restapi import collective.venue import collective.volto.blocksfield import collective.volto.cookieconsent import collective.z3cform.datagridfield +import iosanita.contenttypes import kitconcept.seo import plone.app.caching import plone.formwidget.geolocation -import iosanita.contenttypes -from redturtle.volto.testing import RedturtleVoltoLayer +import plone.restapi class TestLayer(RedturtleVoltoLayer): - def setUpZope(self, app, configurationContext): super().setUpZope(app, configurationContext) self.loadZCML(package=iosanita.contenttypes, context=configurationContext) diff --git a/src/iosanita/contenttypes/tests/xxx_test_ct_event.py b/src/iosanita/contenttypes/tests/xxx_test_ct_event.py index 4624a79..0051b29 100644 --- a/src/iosanita/contenttypes/tests/xxx_test_ct_event.py +++ b/src/iosanita/contenttypes/tests/xxx_test_ct_event.py @@ -2,9 +2,7 @@ from iosanita.contenttypes.interfaces import IIosanitaContenttypes # from iosanita.contenttypes.schema_overrides import SchemaTweaks -from iosanita.contenttypes.testing import ( - IOSANITA_CONTENTTYPES_API_FUNCTIONAL_TESTING, -) +from iosanita.contenttypes.testing import IOSANITA_CONTENTTYPES_API_FUNCTIONAL_TESTING from plone import api from plone.app.testing import setRoles from plone.app.testing import SITE_OWNER_NAME @@ -14,12 +12,14 @@ # from plone.autoform.interfaces import IFormFieldProvider from plone.restapi.testing import RelativeSession -# from zope.component import provideAdapter - import transaction import unittest +# from zope.component import provideAdapter + + + class TestEventSchema(unittest.TestCase): layer = IOSANITA_CONTENTTYPES_API_FUNCTIONAL_TESTING maxDiff = None diff --git a/src/iosanita/contenttypes/vocabularies/reference_vocabularies.py b/src/iosanita/contenttypes/vocabularies/reference_vocabularies.py index bfa2ef4..7d4bd25 100644 --- a/src/iosanita/contenttypes/vocabularies/reference_vocabularies.py +++ b/src/iosanita/contenttypes/vocabularies/reference_vocabularies.py @@ -8,11 +8,11 @@ except ImportError: from Products.CMFPlone.utils import safe_unicode as safe_text +from zope.component.hooks import getSite from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory from zope.schema.vocabulary import SimpleTerm from zope.schema.vocabulary import SimpleVocabulary -from zope.component.hooks import getSite class ReferencesVocabulary(object):