Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Jul 17, 2024
1 parent a5a3d40 commit 35c4f32
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 59 deletions.
2 changes: 1 addition & 1 deletion src/iosanita/contenttypes/adapters/query.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/iosanita/contenttypes/behaviors/a_chi_si_rivolge.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/iosanita/contenttypes/behaviors/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@
provides=".contatti.IContatti"
marker=".contatti.IContatti"
/>
<plone:behavior
<plone:behavior
name="iosanita.contenttypes.behavior.dove"
title="Dove"
description=""
factory=".dove.Dove"
provides=".dove.IDove"
marker=".dove.IDove"
/>
<plone:behavior

<plone:behavior
name="iosanita.contenttypes.behavior.exclude_from_search"
title="Exclude from search"
description="Campo per escludere un contenuto dalle ricerche del sito."
factory=".exclude_from_search.ExcludeFromSearch"
provides=".exclude_from_search.IExcludeFromSearch"
marker=".exclude_from_search.IExcludeFromSearch"
/>
<plone:behavior
<plone:behavior
name="iosanita.contenttypes.behavior.strutture_correlate"
title="Strutture correlate"
description=""
Expand Down Expand Up @@ -99,5 +99,5 @@
for="plone.event.interfaces.IEvent"
marker=".evento.IEvento"
/>

</configure>
14 changes: 6 additions & 8 deletions src/iosanita/contenttypes/behaviors/contatti.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
9 changes: 4 additions & 5 deletions src/iosanita/contenttypes/behaviors/dove.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion src/iosanita/contenttypes/controlpanels/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class IoSanitaSettingsControlpanel(IControlpanel):


class IIoSanitaSettings(Interface):

lead_image_dimension = List(
title=_(
"lead_image_dimension_label",
Expand Down
3 changes: 2 additions & 1 deletion src/iosanita/contenttypes/events/events.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/iosanita/contenttypes/interfaces/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 2 additions & 4 deletions src/iosanita/contenttypes/interfaces/struttura.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 1 addition & 3 deletions src/iosanita/contenttypes/interfaces/unita_organizzativa.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/iosanita/contenttypes/restapi/serializers/persona.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# -*- 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
from zope.component import getUtility
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)
Expand Down Expand Up @@ -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, ""))

Expand Down
6 changes: 3 additions & 3 deletions src/iosanita/contenttypes/setuphandlers.py
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -72,7 +73,6 @@ def post_install(context):


def post_install_taxonomy(context):

try:
for index in [
"tipologia_notizia",
Expand Down
9 changes: 4 additions & 5 deletions src/iosanita/contenttypes/testing.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/iosanita/contenttypes/tests/xxx_test_ct_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 35c4f32

Please sign in to comment.