Skip to content

Commit

Permalink
feat: Adapt helper strxfrm to our needs
Browse files Browse the repository at this point in the history
This helper converts a value into a form that can be used as a sort key - for example, it converts a group's display_name so that a list of groups can be sorted by display_name. Our group titles are multilingual, so we need to localise the value before this can be done.
  • Loading branch information
bellisk committed Nov 13, 2024
1 parent e698168 commit 9a256ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ckanext/switzerland/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,6 @@ def get_wordpress_url():


def strxfrm(s):
"""Overriden from ckan.lib.helpers.strxfrm to handle our multilingual fields.
"""
return unicodedata.normalize('NFD', s).lower()
"""Overriden from ckan.lib.helpers.strxfrm to handle our multilingual fields."""
s = parse_and_localize(s)
return unicodedata.normalize("NFD", s).lower()
2 changes: 2 additions & 0 deletions ckanext/switzerland/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def get_helpers(self):
"group_link": sh.group_link,
"resource_link": sh.resource_link,
"organization_link": sh.organization_link,
"strxfrm": sh.strxfrm,
"get_langs": sh.get_langs,
"localize_change_dict": sh.localize_change_dict,
"get_cookie_law_url": sh.get_cookie_law_url,
Expand Down Expand Up @@ -142,6 +143,7 @@ def organization_facets(self, facets_dict, organization_type, package_type):
h.group_link = sh.group_link
h.resource_link = sh.resource_link
h.organization_link = sh.organization_link
h.strxfrm = sh.strxfrm


class OgdchLanguagePlugin(plugins.SingletonPlugin):
Expand Down

0 comments on commit 9a256ca

Please sign in to comment.