Skip to content

Commit

Permalink
Merge pull request #37 from eea/develop
Browse files Browse the repository at this point in the history
Fix: Latest eea.coremetadata release has issues - refs #273093
  • Loading branch information
avoinea authored Jul 25, 2024
2 parents 984cccc + 627b1ff commit a44e421
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 30 deletions.
5 changes: 5 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

4.1 - (2024-07-25)
---------------------------
* Change: Fix: Latest eea.coremetadata release has issues - refs #273093
[avoinea]

4.0 - (2024-06-21)
---------------------------
* Change: fix(upgrade-script): add try except for KeyError brain.getObjects()
Expand Down
76 changes: 48 additions & 28 deletions eea/coremetadata/behaviors/vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,46 +30,66 @@ def get_catalog_values(context, index):
return catalog.uniqueValuesFor(index)


def eea_other_organisations(context):
"""other_organisations index data"""
catalog = getToolByName(context, "portal_catalog")
idx_object = catalog.Indexes['other_organisations']
terms = [SimpleTerm(item[0], item[0], item[0])
for item in idx_object.items()]
return SimpleVocabulary(terms)


@provider(IVocabularyFactory)
def organisations_vocabulary(context):
"""organisations_vocabulary"""

vocabulary = get_vocabulary(
context, "collective.taxonomy.eeaorganisationstaxonomy"
)
# import pdb
# pdb.set_trace()
return eea_other_organisations(context)
# vocabulary = get_vocabulary(
# context, "collective.taxonomy.eeaorganisationstaxonomy"
# )

terms = [
SimpleTerm(key, key, val.encode("ascii", "ignore").decode("ascii"))
for val, key in vocabulary
]
terms.sort(key=lambda t: t.title)
# terms = [
# SimpleTerm(key, key, val.encode("ascii", "ignore").decode("ascii"))
# for val, key in vocabulary
# ]
# # import pdb
# # pdb.set_trace()
# terms.sort(key=lambda t: t.title)

return SimpleVocabulary(terms)
# return SimpleVocabulary(terms)


@provider(IVocabularyFactory)
def index_organisations_vocabulary(context):
"""index_organisations_vocabulary"""

catalog_values = get_catalog_values(
context, "taxonomy_eeaorganisationstaxonomy"
)
vocabulary = get_vocabulary(
context, "collective.taxonomy.eeaorganisationstaxonomy"
)
terms = []

for val, key in vocabulary:
if key in catalog_values:
terms.append(
SimpleTerm(
key, key, val.encode("ascii", "ignore").decode("ascii")
)
)

terms.sort(key=lambda t: t.title)

return SimpleVocabulary(terms)
# import pdb
# pdb.set_trace()
return eea_other_organisations(context)

# catalog_values = get_catalog_values(
# context, "taxonomy_eeaorganisationstaxonomy"
# )
# vocabulary = get_vocabulary(
# context, "collective.taxonomy.eeaorganisationstaxonomy"
# )
# terms = []

# # import pdb
# # pdb.set_trace()
# for val, key in vocabulary:
# if key in catalog_values:
# terms.append(
# SimpleTerm(
# key, key, val.encode("ascii", "ignore").decode("ascii")
# )
# )

# terms.sort(key=lambda t: t.title)

# return SimpleVocabulary(terms)


@provider(IVocabularyFactory)
Expand Down
5 changes: 5 additions & 0 deletions eea/coremetadata/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@
name="eea.coremetadata.other_organisations"
component=".vocabulary.OtherOrganisationsVocabularyFactory"
/>
<utility
factory=".index_modifiers.OtherOrganisations"
provides="plone.app.querystring.interfaces.IParsedQueryIndexModifier"
name="taxonomy_eeaorganisationstaxonomy"
/>
</configure>
15 changes: 15 additions & 0 deletions eea/coremetadata/index_modifiers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Modify indexer."""

from plone.app.querystring.interfaces import IParsedQueryIndexModifier
from zope.interface import implementer


@implementer(IParsedQueryIndexModifier)
class OtherOrganisations(object):
""" Get other_organisation index instead taxonomy_eeaorganisationstaxonomy
"""

def __call__(self, value):
"""
"""
return ("other_organisations", value)
2 changes: 1 addition & 1 deletion eea/coremetadata/profiles/default/catalog.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<object name="portal_catalog">

<index name="taxonomy_eeaorganisationstaxonomy" meta_type="KeywordIndex">
<index name="other_organisations" meta_type="KeywordIndex">
<indexed_attr value="other_organisations"/>
</index>

Expand Down
2 changes: 1 addition & 1 deletion eea/coremetadata/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
4.1

0 comments on commit a44e421

Please sign in to comment.