Skip to content
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

Fix/fix adding dataset to groups #134

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 \
stefina marked this conversation as resolved.
Show resolved Hide resolved
-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
Loading