diff --git a/src/iosanita/contenttypes/behaviors/configure.zcml b/src/iosanita/contenttypes/behaviors/configure.zcml index cd7140c..417a836 100644 --- a/src/iosanita/contenttypes/behaviors/configure.zcml +++ b/src/iosanita/contenttypes/behaviors/configure.zcml @@ -28,15 +28,6 @@ for="plone.dexterity.interfaces.IDexterityContent" marker=".servizi.IServizi" /> - - diff --git a/src/iosanita/contenttypes/indexers/common.py b/src/iosanita/contenttypes/indexers/common.py index c3ad4fb..b6c389d 100644 --- a/src/iosanita/contenttypes/indexers/common.py +++ b/src/iosanita/contenttypes/indexers/common.py @@ -3,30 +3,6 @@ from plone.indexer.decorator import indexer -@indexer(IDexterityContent) -def parliamo_di(context, **kw): - return [ - x.to_object.Title() - for x in getattr(context.aq_base, "parliamo_di", []) - if x.to_object - ] - - -@indexer(IDexterityContent) -def parliamo_di_uid(context, **kw): - return [ - x.to_object.UID() - for x in getattr(context.aq_base, "parliamo_di", []) - if x.to_object - ] - - -@indexer(IDexterityContent) -def ufficio_responsabile(context, **kw): - uffici = getattr(context.aq_base, "ufficio_responsabile", []) - return [ufficio.UID() for ufficio in filter(bool, [x.to_object for x in uffici])] - - @indexer(IDexterityContent) def parent(context): obj_parent = context.aq_parent diff --git a/src/iosanita/contenttypes/indexers/configure.zcml b/src/iosanita/contenttypes/indexers/configure.zcml index 98a95f6..e0e401b 100644 --- a/src/iosanita/contenttypes/indexers/configure.zcml +++ b/src/iosanita/contenttypes/indexers/configure.zcml @@ -4,18 +4,6 @@ factory=".events.event_location" name="event_location" /> - - - - - - - - diff --git a/src/iosanita/contenttypes/vocabularies/mockup.py b/src/iosanita/contenttypes/vocabularies/mockup.py deleted file mode 100644 index 2fc7d8e..0000000 --- a/src/iosanita/contenttypes/vocabularies/mockup.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -from iosanita.contenttypes import _ -from plone.dexterity.interfaces import IDexterityContent -from zope.globalrequest import getRequest -from zope.interface import implementer -from zope.schema.interfaces import IVocabularyFactory -from zope.schema.vocabulary import SimpleTerm -from zope.schema.vocabulary import SimpleVocabulary - - -class VocabItem(object): - def __init__(self, token, value): - self.token = token - self.value = value - - -@implementer(IVocabularyFactory) -class Mockup(object): - """ """ - - def __call__(self, context): - # Just an example list of content for our vocabulary, - # this can be any static or dynamic data, a catalog result for example. - items = [ - VocabItem("sony-a7r-iii", _("Sony Aplha 7R III")), - VocabItem("canon-5d-iv", _("Canon 5D IV")), - VocabItem("pippo", _("Pippo")), - VocabItem("pluto", _("Pluto")), - VocabItem("paperino", _("Paperino")), - VocabItem("giovanni", _("Giovanni")), - ] - - # Fix context if you are using the vocabulary in DataGridField. - # See https://github.com/collective/collective.z3cform.datagridfield/issues/31: # NOQA: 501 - if not IDexterityContent.providedBy(context): - req = getRequest() - context = req.PARENTS[0] - - # create a list of SimpleTerm items: - terms = [] - for item in items: - terms.append( - SimpleTerm(value=item.token, token=str(item.token), title=item.value) - ) - # Create a SimpleVocabulary from the terms list and return it: - return SimpleVocabulary(terms) - - -MockupFactory = Mockup() diff --git a/src/iosanita/contenttypes/vocabularies/reference_vocabularies.py b/src/iosanita/contenttypes/vocabularies/reference_vocabularies.py deleted file mode 100644 index 7d4bd25..0000000 --- a/src/iosanita/contenttypes/vocabularies/reference_vocabularies.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- - -from Products.CMFCore.utils import getToolByName - - -try: - from plone.base.utils import safe_text -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 - - -class ReferencesVocabulary(object): - INDEX = "" - - def get_all_index_values(self): - index = self.catalog._catalog.getIndex(self.INDEX) - return list(index.uniqueValues()) - - def __call__(self, registry=None): - site = getSite() - self.catalog = getToolByName(site, "portal_catalog", None) - if self.catalog is None: - return SimpleVocabulary([]) - values = self.get_all_index_values() - brains = self.catalog(UID=values) - terms = [] - for brain in brains: - terms.append(SimpleTerm(brain.UID, brain.UID, safe_text(brain.Title))) - return SimpleVocabulary(terms) - - -@implementer(IVocabularyFactory) -class EventLocationVocabulary(ReferencesVocabulary): - INDEX = "event_location" - - -@implementer(IVocabularyFactory) -class OfficeLocationVocabulary(ReferencesVocabulary): - INDEX = "ufficio_responsabile" - - -@implementer(IVocabularyFactory) -class UOLocationVocabulary(ReferencesVocabulary): - INDEX = "uo_location" - - -EventLocationVocabularyFactory = EventLocationVocabulary() -OfficeLocationVocabularyFactory = OfficeLocationVocabulary() -UOLocationVocabularyFactory = UOLocationVocabulary()