diff --git a/CHANGES.rst b/CHANGES.rst index 63fc810..79dd662 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,9 @@ Changelog 1.2.2 (unreleased) ------------------ -- Nothing changed yet. +- Fix missing values for topics / iam lists (causing `None` in REST views filters) + See https://github.com/collective/collective.solr/issues/366 + [laulaz] 1.2.1 (2023-10-26) diff --git a/src/imio/directory/core/contents/contact/content.py b/src/imio/directory/core/contents/contact/content.py index 30f0eb1..ca6f7e5 100644 --- a/src/imio/directory/core/contents/contact/content.py +++ b/src/imio/directory/core/contents/contact/content.py @@ -337,6 +337,7 @@ class IContact( "Important! These categories make it possible to highlight and geolocate certain basic services" ), value_type=schema.Choice(vocabulary="imio.directory.vocabulary.Facilities"), + default=[], required=False, ) directives.widget(facilities=SelectFieldWidget) diff --git a/src/imio/directory/core/profiles/default/metadata.xml b/src/imio/directory/core/profiles/default/metadata.xml index e0122cc..5cae0f4 100644 --- a/src/imio/directory/core/profiles/default/metadata.xml +++ b/src/imio/directory/core/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 1011 + 1012 profile-plone.app.dexterity:default profile-plone.gallery:default diff --git a/src/imio/directory/core/upgrades/configure.zcml b/src/imio/directory/core/upgrades/configure.zcml index 9cb8a09..b49c4d6 100644 --- a/src/imio/directory/core/upgrades/configure.zcml +++ b/src/imio/directory/core/upgrades/configure.zcml @@ -124,4 +124,13 @@ profile="imio.directory.core:default" /> + + diff --git a/src/imio/directory/core/upgrades/upgrades.py b/src/imio/directory/core/upgrades/upgrades.py index a12beee..fefbd9e 100644 --- a/src/imio/directory/core/upgrades/upgrades.py +++ b/src/imio/directory/core/upgrades/upgrades.py @@ -204,3 +204,15 @@ def fix_type(contact, field_name): fix_type(contact, "private_phones") fix_type(contact, "private_mails") fix_type(contact, "private_urls") + + +def fix_missing_values_for_facilities_lists(context): + catalog = api.portal.get_tool("portal_catalog") + with api.env.adopt_user(username="admin"): + brains = api.content.find(portal_type=["imio.directory.Contact"]) + for brain in brains: + obj = brain.getObject() + if hasattr(obj, "facilities") and obj.facilities is None: + obj.facilities = [] + catalog.catalog_object(obj, idxs=["facilities"]) + logger.info(f"Fixed None list for Facilities on {obj.absolute_url()}")