Skip to content

Commit

Permalink
updated Evento, Document and Step ct
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-andreotti committed Jul 12, 2024
1 parent 6ced6f1 commit 9390b9c
Show file tree
Hide file tree
Showing 27 changed files with 849 additions and 47 deletions.
Empty file.
24 changes: 24 additions & 0 deletions src/iosanita/contenttypes/adapters/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
>

<!-- <adapter
factory=".servizi_correlati.GetCorrelatiServizi"
provides=".interfaces.ICorrelati"
for="design.plone.contenttypes.interfaces.servizio.IServizio
zope.publisher.interfaces.browser.IHTTPRequest"
name="correlati-servizi"
/>
<adapter factory=".searchabletext_indexers.RelationChoiceFieldConverter" />
<adapter factory=".searchabletext_indexers.RelationListFieldConverter" />
<adapter
factory=".searchabletext_indexers.TextBlockSearchableText"
name="text"
/> -->

<adapter factory=".query.ZCatalogCompatibleQueryAdapter" />

</configure>
26 changes: 26 additions & 0 deletions src/iosanita/contenttypes/adapters/query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from iosanita.contenttypes.interfaces import IIosanitaContenttypesLayer
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)
@adapter(Interface, IIosanitaContenttypesLayer)
class ZCatalogCompatibleQueryAdapter(BaseAdapter):
""" """

def __call__(self, query):
"""
Do not show excluded from search items when anonymous are performing
some catalog searches
"""
query = super().__call__(query=query)

if api.user.is_anonymous():
# For the anonymous user, only content that is not "excluded from the search" is found
query["exclude_from_search"] = False

return query
25 changes: 16 additions & 9 deletions src/iosanita/contenttypes/behaviors/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@
provides=".contatti.IContattiUnitaOrganizzativa"
marker=".contatti.IContattiUnitaOrganizzativa"
/>
<plone:behavior
name="iosanita.contenttypes.behavior.contatti_step"
title="Contatti"
description="Behavior contatti per Step."
factory=".contatti.ContattiStep"
provides=".contatti.IContattiStep"
marker=".contatti.IContattiStep"
/>
<plone:behavior
name="iosanita.contenttypes.behavior.address_event"
title="Address Event"
Expand Down Expand Up @@ -158,5 +150,20 @@
provides=".contatti.IContattiPersona"
marker=".contatti.IContattiPersona"
/>

<plone:behavior
name="iosanita.contenttypes.behavior.contatti_step"
title="Contatti"
description="Behavior contatti per Step."
factory=".contatti.ContattiStep"
provides=".contatti.IContattiStep"
marker=".contatti.IContattiStep"
/>
<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"
/>
</configure>
49 changes: 40 additions & 9 deletions src/iosanita/contenttypes/behaviors/contatti.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

from iosanita.contenttypes import _
from iosanita.contenttypes.interfaces.persona import IPersona
from iosanita.contenttypes.interfaces.step import IStep

from iosanita.contenttypes.interfaces.unita_organizzativa import IUnitaOrganizzativa


Expand Down Expand Up @@ -61,29 +63,48 @@ class IContattiUnitaOrganizzativa(model.Schema):


@provider(IFormFieldProvider)
class IContattiStep(model.Schema):
class IContattiEvent(model.Schema):
contact_info = RelationList(
title=_(
"contact_info_label",
default="Contatti",
default="Punti di contatto",
),
description=_(
"contatti_step_contact_info_help",
default="I contatti per questo step.",
"contact_info_help",
default="Relazione con i punti di contatto dell'evento.",
),
required=True,
default=[],
value_type=RelationChoice(
title=_("Punti di contatto"),
vocabulary="plone.app.vocabularies.Catalog",
),
)
form.widget(
"contact_info",
RelatedItemsFieldWidget,
vocabulary="plone.app.vocabularies.Catalog",
pattern_options={
"selectableTypes": ["PuntoDiContatto"],
},
)
model.fieldset(
"contatti",
label=_("contatti_label", default="Contatti"),
fields=["contact_info"],
)


@provider(IFormFieldProvider)
class IContattiEvent(model.Schema):
class IContattiPersona(model.Schema):
contact_info = RelationList(
title=_(
"contatti_event_contact_info_label",
default="Punti di contatto",
),
description=_(
"contatti_event_contact_info_help",
default="Relazione con i punti di contatto dell'evento.",
"contact_info_help",
default="Punti di contatto della persona.",
),
required=True,
default=[],
Expand All @@ -92,6 +113,7 @@ class IContattiEvent(model.Schema):
vocabulary="plone.app.vocabularies.Catalog",
),
)

form.widget(
"contact_info",
RelatedItemsFieldWidget,
Expand All @@ -108,15 +130,15 @@ class IContattiEvent(model.Schema):


@provider(IFormFieldProvider)
class IContattiPersona(model.Schema):
class IContattiStep(model.Schema):
contact_info = RelationList(
title=_(
"contatti_persona_contact_info_label",
default="Punti di contatto",
),
description=_(
"contact_info_help",
default="Punti di contatto della persona.",
default="Punti di contatto per questo passo.",
),
required=True,
default=[],
Expand Down Expand Up @@ -175,3 +197,12 @@ class ContattiPersona(object):

def __init__(self, context):
self.context = context


@implementer(IContattiStep)
@adapter(IStep)
class ContattiStep(object):
""" """

def __init__(self, context):
self.context = context
37 changes: 37 additions & 0 deletions src/iosanita/contenttypes/behaviors/exclude_from_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
from iosanita.contenttypes import _
from plone.autoform.interfaces import IFormFieldProvider
from plone.dexterity.interfaces import IDexterityContent
from plone.supermodel import model
from zope import schema
from zope.component import adapter
from zope.interface import implementer
from zope.interface import provider


@provider(IFormFieldProvider)
class IExcludeFromSearch(model.Schema):
""" """

exclude_from_search = schema.Bool(
title=_("exclude_from_search_label", default="Escludi dalla ricerca"),
description=_(
"help_exclude_from_search",
default="Se selezionato, questo contenuto non verrà mostrato nelle ricerche del sito per gli utenti anonimi.",
),
required=False,
default=False,
)
model.fieldset(
"settings",
fields=["exclude_from_search"],
)


@implementer(IExcludeFromSearch)
@adapter(IDexterityContent)
class ExcludeFromSearch(object):
""" """

def __init__(self, context):
self.context = context
4 changes: 2 additions & 2 deletions src/iosanita/contenttypes/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@


<include package=".browser" />
<!-- <include package=".adapters" /> -->
<include package=".adapters" />
<include package=".behaviors" />
<include package=".browser" />
<!-- <include package=".controlpanels" /> -->
<include package=".controlpanels" />
<include package=".events" />
<include package=".indexers" />
<include package=".restapi" />
Expand Down
9 changes: 9 additions & 0 deletions src/iosanita/contenttypes/content/punto_di_contatto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from iosanita.contenttypes.interfaces.punto_di_contatto import IPuntoDiContatto
from plone.dexterity.content import Container
from zope.interface import implementer


@implementer(IPuntoDiContatto)
class PuntoDiContatto(Container):
""" """
Empty file.
20 changes: 20 additions & 0 deletions src/iosanita/contenttypes/controlpanels/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="iosanita.contenttypes"
>

<include
package="Products.CMFCore"
file="permissions.zcml"
/>

<browser:page
name="io-sanita-settings"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".settings.IoSanitaControlPanelView"
permission="cmf.ManagePortal"
/>

</configure>
84 changes: 84 additions & 0 deletions src/iosanita/contenttypes/controlpanels/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-
from iosanita.contenttypes import _
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
from plone.app.registry.browser.controlpanel import RegistryEditForm
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 IoSanitaSettingsControlpanel(IControlpanel):
""" """


class IIoSanitaSettings(Interface):

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,
)


class IoSanitaControlPanelForm(RegistryEditForm):
schema = IIoSanitaSettings
id = "io-sanita-control-panel"
label = _("Impostazioni Io sanita")


class IoSanitaControlPanelView(ControlPanelFormWrapper):
""" """

form = IoSanitaControlPanelForm
Loading

0 comments on commit 9390b9c

Please sign in to comment.