-
Notifications
You must be signed in to change notification settings - Fork 7
Add registry setting for int fields #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <metadata> | ||
| <version>12</version> | ||
| <version>13</version> | ||
| </metadata> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <metadata> | ||
| <version>13</version> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update profiles do not need a |
||
| </metadata> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <registry> | ||
| <record name="collective.collectionfilter.int_types"> | ||
| <field type="plone.registry.field.Tuple"> | ||
| <title>Target Collection Types</title> | ||
| <description>A list of fields that are int</description> | ||
| <value_type type="plone.registry.field.TextLine" /> | ||
| </field> | ||
| <value> | ||
| <element>intfield</element> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above -> empty initialization per default |
||
| </value> | ||
| </record> | ||
| </registry> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,3 +98,7 @@ def upgrade_to_plone6(context): | |
| del registry.records[key] | ||
|
|
||
| reapply_profile(context) | ||
|
|
||
| def upgrade_registry_13(context): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you only want to reload an existing |
||
| # Probably not needed | ||
| reapply_profile(context) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -100,5 +100,13 @@ | |||||||||||||||||||||||||||||||||||
| handler=".upgrades.upgrade_to_plone6" | ||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| <genericsetup:upgradeStep | ||||||||||||||||||||||||||||||||||||
| title="collective.collectionfilter: Upgrade v12 to v13" | ||||||||||||||||||||||||||||||||||||
| description="upgrade to version 13" | ||||||||||||||||||||||||||||||||||||
| source="12" | ||||||||||||||||||||||||||||||||||||
| destination="13" | ||||||||||||||||||||||||||||||||||||
| profile="collective.collectionfilter:upgrade-13" | ||||||||||||||||||||||||||||||||||||
| handler=".upgrades.upgrade_registry_13" | ||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
Comment on lines
+103
to
111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And the registration of the upgrade profile |
||||||||||||||||||||||||||||||||||||
| </configure> | ||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,11 +20,17 @@ | |
|
|
||
| import plone.api | ||
|
|
||
| from zope.interface.interfaces import ComponentLookupError | ||
|
|
||
|
|
||
| # Use this EMPTY_MARKER for your custom indexer to index empty criterions. | ||
| EMPTY_MARKER = "__EMPTY__" | ||
| TEXT_IDX = "SearchableText" | ||
|
|
||
| # integer ids are stored in the registry | ||
| # But not before version upgrade | ||
| INTEGER_IDXS = [] | ||
|
|
||
| GEOLOC_IDX = [ | ||
| "latitude", | ||
| "longitude", | ||
|
|
@@ -140,6 +146,16 @@ def groupby(self): | |
| return self._groupby | ||
| self._groupby = {} | ||
|
|
||
| # Use 'try' since it broke before update | ||
| # Maybe move this code to GroupByCriteria | ||
| try: | ||
| INTEGER_IDXS = plone.api.portal.get_registry_record( | ||
| "collective.collectionfilter.int_types", default=[] | ||
| ) | ||
| except ComponentLookupError: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought registry lookup errors are handled in
See https://6.docs.plone.org/plone.api/about.html#design-decisions |
||
| INTEGER_IDXS = [] | ||
|
|
||
|
|
||
| cat = plone.api.portal.get_tool("portal_catalog") | ||
| # get catalog metadata schema, but filter out items which cannot be | ||
| # used for grouping | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a project individual value. The default in the package is empty, so I would initialize it empty here too.