Good afternoon, Plone community!
I am trying to prepare a Plone Classic addon to work in the Volto Frontend. However, I am unable to see why the custom vocabulary for the unit goal works fine in Plone Classic but fails to render in Volto. The python code below was what I was using to render the vocabulary in Plone Classic:
from zope.interface import implementer
from zope.schema.interfaces import IVocabularyFactory
from plone.app.vocabularies.catalog import KeywordsVocabulary as BKV
from plone import api
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
from yc.assessment import _
@implementer(IVocabularyFactory)
class AvailableUnitGoals(BKV):
"""
"""
keyword_index = None
def __init__(self, index):
self.keyword_index = index
def __call__(self, context):
results = []
if not str(context.portal_type).startswith('Plone Site'):
unit = context.define_unit
brains = api.content.find(
portal_type='unit_goal',
sort_on='sortable_title',
unit=unit,
)
# brains_unique = []
# for brain in brains:
# if brain.Title not in brains_unique:
# brains_unique.append(brain.Title)
for brain in brains:
results.append(SimpleTerm(value=brain.Title, title=brain.Title, ))
# Create a SimpleVocabulary from the terms list and return it:
return SimpleVocabulary(results)
AvailableUnitGoalsFactory = AvailableUnitGoals('unit_goal')
The preceding code was designed to pull in the unit goals manually entered into the system by the user. Basically, the goals the user manually submits is in theory supposed to display and only display the appropriate unit goals for the current unit it is contained in.
Any suggestions on how to tackle this issue? I did see a post from @tiberiuichim which talked about keywords-vocabulary and I did attempt to use it. It did display all the unit goals as entered into the system regardless of the correct or incorrect unit, but failed to filter by the individual unit.
For reference here is the article I saw:
https://github.com/plone/volto/issues/3020
I am running Plone 6.0.4 and Volto 16.20.6.
I thank you kindly.
rbrown12