Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Sep 8, 2023
1 parent d984533 commit 8da0d23
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 82 deletions.
41 changes: 41 additions & 0 deletions src/design/plone/contenttypes/behaviors/v3/documento.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# -*- coding: utf-8 -*-
from collective.volto.blocksfield.field import BlocksField
from design.plone.contenttypes import _
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 import schema
from zope.component import adapter
from zope.interface import implementer
Expand All @@ -13,6 +16,22 @@

@provider(IFormFieldProvider)
class IDocumentoBehavior(model.Schema):
ufficio_responsabile = RelationList(
title=_(
"ufficio_responsabile_documento_label",
default="Ufficio responsabile del documento",
),
description=_(
"ufficio_responsabile_documento_help",
default="Seleziona l'ufficio responsabile di questo documento.",
),
required=True,
default=[],
value_type=RelationChoice(
title=_("Ufficio responsabile"),
vocabulary="plone.app.vocabularies.Catalog",
),
)
protocollo = schema.TextLine(
title=_(
"protocollo_documento_label",
Expand All @@ -39,10 +58,32 @@ class IDocumentoBehavior(model.Schema):
required=True,
)

form.order_after(
ufficio_responsabile="IDescrizioneEstesaDocumento.descrizione_estesa"
)
form.order_after(formati_disponibili="identificativo")
form.order_after(data_protocollo="identificativo")
form.order_after(protocollo="identificativo")

form.widget(
"ufficio_responsabile",
RelatedItemsFieldWidget,
vocabulary="plone.app.vocabularies.Catalog",
pattern_options={
"maximumSelectionSize": 1,
"selectableTypes": ["UnitaOrganizzativa"],
},
)

#  custom fieldsets
model.fieldset(
"descrizione",
label=_("descrizione_label", default="Descrizione"),
fields=[
"ufficio_responsabile",
],
)


@implementer(IDocumentoBehavior)
@adapter(IDexterityContent)
Expand Down
8 changes: 7 additions & 1 deletion src/design/plone/contenttypes/behaviors/v3/servizio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from collective.z3cform.datagridfield.row import DictRow
from collective.z3cform.datagridfield.datagridfield import DataGridFieldFactory
from design.plone.contenttypes import _
from plone.app.dexterity import textindexer
from plone.app.z3cform.widget import DateFieldWidget
from plone.app.z3cform.widgets.link import LinkFieldWidget
from plone.app.z3cform.widget import LinkFieldWidget
from plone.app.z3cform.widget import RelatedItemsFieldWidget
from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform import directives as form
Expand Down Expand Up @@ -196,6 +197,11 @@ class IServizioBehavior(model.Schema):
fields=["a_chi_si_rivolge"],
)

textindexer.searchable("ulteriori_informazioni")
textindexer.searchable("a_chi_si_rivolge")
textindexer.searchable("come_si_fa")
textindexer.searchable("cosa_si_ottiene")


@implementer(IServizioBehavior)
@adapter(IDexterityContent)
Expand Down
33 changes: 2 additions & 31 deletions src/design/plone/contenttypes/interfaces/documento.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class IDocumento(model.Schema, IDesignPloneContentType):
identificativo = schema.TextLine(
title=_(
"identificativo_documento_label",
default="Identificativo del documento.",
default="Identificativo del documento",
),
description=_(
"identificativo_documento_help",
Expand All @@ -25,23 +25,6 @@ class IDocumento(model.Schema, IDesignPloneContentType):
required=False,
)

ufficio_responsabile = RelationList(
title=_(
"ufficio_responsabile_documento_label",
default="Ufficio responsabile del documento",
),
description=_(
"ufficio_responsabile_documento_help",
default="Seleziona l'ufficio responsabile di questo documento.",
),
required=True,
default=[],
value_type=RelationChoice(
title=_("Ufficio responsabile"),
vocabulary="plone.app.vocabularies.Catalog",
),
)

area_responsabile = RelationList(
title=_(
"area_responsabile_label",
Expand Down Expand Up @@ -111,15 +94,6 @@ class IDocumento(model.Schema, IDesignPloneContentType):
)

# custom widgets
form.widget(
"ufficio_responsabile",
RelatedItemsFieldWidget,
vocabulary="plone.app.vocabularies.Catalog",
pattern_options={
"maximumSelectionSize": 1,
"selectableTypes": ["UnitaOrganizzativa"],
},
)

form.widget(
"autori",
Expand Down Expand Up @@ -151,7 +125,6 @@ class IDocumento(model.Schema, IDesignPloneContentType):
"descrizione",
label=_("descrizione_label", default="Descrizione"),
fields=[
"ufficio_responsabile",
"area_responsabile",
"autori",
"licenza_distribuzione",
Expand All @@ -165,9 +138,7 @@ class IDocumento(model.Schema, IDesignPloneContentType):
)

# custom order
form.order_after(
ufficio_responsabile="IDescrizioneEstesaDocumento.descrizione_estesa"
)

form.order_after(area_responsabile="ufficio_responsabile")
form.order_after(autori="area_responsabile")
form.order_after(
Expand Down
4 changes: 0 additions & 4 deletions src/design/plone/contenttypes/interfaces/servizio.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,8 @@ class IServizio(model.Schema, IDesignPloneContentType):
model.fieldset("informazioni", fields=["codice_ipa", "settore_merceologico"])

# SearchableText fields
# TODO da verificare in base a v2/v3
textindexer.searchable("sottotitolo")
textindexer.searchable("a_chi_si_rivolge")
textindexer.searchable("chi_puo_presentare")
textindexer.searchable("come_si_fa")
textindexer.searchable("cosa_si_ottiene")
textindexer.searchable("cosa_serve")
textindexer.searchable("area")
textindexer.searchable("ufficio_responsabile")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setUp(self):
"""Custom shared utility setup for tests."""
self.portal = self.layer["portal"]

def test_behaviors_enabled_for_documento(self):
def test_behaviors_enabled_for_cartella_modulistica(self):
portal_types = api.portal.get_tool(name="portal_types")
self.assertEqual(
portal_types["CartellaModulistica"].behaviors,
Expand Down
3 changes: 2 additions & 1 deletion src/design/plone/contenttypes/tests/test_ct_documento.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def test_behaviors_enabled_for_documento(self):
"plone.constraintypes",
"plone.leadimage",
"volto.preview_image",
"design.plone.contenttypes.behavior.documento_additional_fields",
"design.plone.contenttypes.behavior.argomenti_documento",
"design.plone.contenttypes.behavior.descrizione_estesa_documento", # noqa
"design.plone.contenttypes.behavior.descrizione_estesa_documento",
"design.plone.contenttypes.behavior.additional_help_infos",
"plone.textindexer",
"plone.translatable",
Expand Down
39 changes: 0 additions & 39 deletions src/design/plone/contenttypes/tests/test_ct_documento_personale.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/design/plone/contenttypes/tests/test_ct_modulo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import unittest


class TestDocument(unittest.TestCase):
class TestModulo(unittest.TestCase):
layer = DESIGN_PLONE_CONTENTTYPES_INTEGRATION_TESTING

def setUp(self):
"""Custom shared utility setup for tests."""
self.portal = self.layer["portal"]

def test_behaviors_enabled_for_documento(self):
def test_behaviors_enabled_for_modulo(self):
portal_types = api.portal.get_tool(name="portal_types")
self.assertEqual(
portal_types["Modulo"].behaviors,
Expand Down
1 change: 1 addition & 0 deletions src/design/plone/contenttypes/tests/test_ct_persona.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_behaviors_enabled_for_persona(self):
"plone.categorization",
"plone.basic",
"plone.locking",
"design.plone.contenttypes.behavior.persona_additional_fields",
"design.plone.contenttypes.behavior.additional_help_infos",
"design.plone.contenttypes.behavior.contatti_persona",
"plone.textindexer",
Expand Down
3 changes: 2 additions & 1 deletion src/design/plone/contenttypes/tests/test_ct_servizio.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_behaviors_enabled_for_servizio(self):
"plone.categorization",
"plone.basic",
"design.plone.contenttypes.behavior.descrizione_estesa_servizio",
"plone.locking",
"design.plone.contenttypes.behavior.servizio_additional_fields",
"plone.leadimage",
"volto.preview_image",
"plone.relateditems",
Expand All @@ -78,6 +78,7 @@ def test_behaviors_enabled_for_servizio(self):
"plone.translatable",
"kitconcept.seo",
"plone.versioning",
"plone.locking",
"collective.taxonomy.generated.person_life_events",
"collective.taxonomy.generated.business_events",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ def test_behaviors_enabled_for_uo(self):
"plone.leadimage",
"volto.preview_image",
"plone.relateditems",
# "design.plone.contenttypes.behavior.address_uo",
# "design.plone.contenttypes.behavior.geolocation_uo",
"design.plone.contenttypes.behavior.unita_organizzativa_additional_fields",
"design.plone.contenttypes.behavior.contatti_uo",
"design.plone.contenttypes.behavior.argomenti",
"plone.textindexer",
Expand Down

0 comments on commit 8da0d23

Please sign in to comment.