Skip to content

Commit

Permalink
Merge pull request #134 from liip/fix/fix-adding-dataset-to-groups
Browse files Browse the repository at this point in the history
Fix/fix adding dataset to groups
  • Loading branch information
bellisk authored Nov 18, 2024
2 parents 34b90ea + 0011d07 commit e47e4a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Create ckan container
run: |
/usr/bin/docker create --name test_ckan --network ${{ job.container.network }} --network-alias ckan \
--env-file ${{ github.workspace }}/github-workflow.env \
--env-file ${{ github.workspace }}/github-workflow.env --user root \
-v "/var/run/docker.sock":"/var/run/docker.sock" \
-v "/home/runner/work":"/__w" -v "/home/runner/work/_temp":"/__w/_temp" \
-v "/home/runner/work/_actions":"/__w/_actions" -v "/opt/hostedtoolcache":"/__t" \
Expand Down
11 changes: 9 additions & 2 deletions ckanext/switzerland/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import logging
import os
import unicodedata
from collections import defaultdict
from datetime import datetime
from zoneinfo import ZoneInfo
Expand Down Expand Up @@ -49,7 +50,7 @@ def get_localized_value(lang_dict, desired_lang_code=None, default_value=""):

# if no specific lang is requested, read from environment
if desired_lang_code is None:
desired_lang_code = tk.request.environ["CKAN_LANG"]
desired_lang_code = get_request_language()

try:
# return desired lang if available
Expand Down Expand Up @@ -470,9 +471,15 @@ def index_language_specific_values(search_data, validated_dict):
def get_request_language():
try:
return tk.request.environ["CKAN_LANG"]
except TypeError:
except (RuntimeError, TypeError):
return tk.config.get("ckan.locale_default", "en")


def get_wordpress_url():
return tk.config.get("ckanext.switzerland.wp_url")


def strxfrm(s):
"""Overriden from ckan.lib.helpers.strxfrm to handle our multilingual fields."""
s = parse_and_localize(s)
return unicodedata.normalize("NFD", s).lower()
3 changes: 3 additions & 0 deletions ckanext/switzerland/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def get_helpers(self):
"group_link": sh.group_link,
"resource_link": sh.resource_link,
"organization_link": sh.organization_link,
"strxfrm": sh.strxfrm,
# end monkey-patched helpers
"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 +144,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 e47e4a6

Please sign in to comment.