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

[Fixes #9862] Thesaurus label are not available with default language #9864

Merged
merged 4 commits into from
Aug 24, 2022
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
4 changes: 2 additions & 2 deletions geonode/base/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from geonode.base.fields import MultiThesauriField
from geonode.documents.models import Document
from geonode.layers.models import Dataset
from geonode.base.utils import validate_extra_metadata, remove_country_from_lanugecode
from geonode.base.utils import validate_extra_metadata, remove_country_from_languagecode

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -351,7 +351,7 @@ def _get_thesauro_keyword_label(item, lang):
# try find results found for given language e.g. (en-us) if no results found remove country code from language to (en) and try again
qs_keyword_ids = ThesaurusKeywordLabel.objects.filter(lang=lang, keyword_id__in=keyword_id_for_given_thesaurus).values("keyword_id")
if len(qs_keyword_ids) == 0:
lang = remove_country_from_lanugecode(lang)
lang = remove_country_from_languagecode(lang)
qs_keyword_ids = ThesaurusKeywordLabel.objects.filter(lang=lang, keyword_id__in=keyword_id_for_given_thesaurus).values("keyword_id")

not_qs_ids = ThesaurusKeywordLabel.objects.exclude(keyword_id__in=qs_keyword_ids).order_by("keyword_id").distinct("keyword_id").values("keyword_id")
Expand Down
3 changes: 1 addition & 2 deletions geonode/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ def validate_extra_metadata(data, instance):
return data


@staticmethod
def remove_country_from_lanugecode(language: str):
def remove_country_from_languagecode(language: str):
""" Remove country code (us) from language name (en-us)
>>> remove_country_from_lanugecode("en-us")
'en'
Expand Down
4 changes: 2 additions & 2 deletions geonode/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from geonode.resource.manager import resource_manager
from geonode.security.utils import get_visible_resources
from geonode.notifications_helper import send_notification
from geonode.base.utils import OwnerRightsRequestViewUtils, remove_country_from_lanugecode
from geonode.base.utils import OwnerRightsRequestViewUtils, remove_country_from_languagecode
from geonode.base.forms import UserAndGroupPermissionsForm

from geonode.base.forms import (
Expand Down Expand Up @@ -310,7 +310,7 @@ def get_queryset(self):
# try find results found for given language e.g. (en-us) if no results found remove country code from language to (en) and try again
qs_keyword_ids = ThesaurusKeywordLabel.objects.filter(lang=lang, keyword_id__in=keyword_id_for_given_thesaurus).values("keyword_id")
if len(qs_keyword_ids) == 0:
lang = remove_country_from_lanugecode(lang)
lang = remove_country_from_languagecode(lang)
qs_keyword_ids = ThesaurusKeywordLabel.objects.filter(lang=lang, keyword_id__in=keyword_id_for_given_thesaurus).values("keyword_id")

not_qs_ids = ThesaurusKeywordLabel.objects.exclude(keyword_id__in=qs_keyword_ids).order_by("keyword_id").distinct("keyword_id").values("keyword_id")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ wrapt==1.14.1
jsonschema==4.14.0
zipstream-new==1.1.8
schema==0.7.5
rdflib==6.2.0
rdflib==6.1.1
smart_open==6.1.0

# Django Apps
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ install_requires =
jsonschema==4.14.0
zipstream-new==1.1.8
schema==0.7.5
rdflib==6.2.0
rdflib==6.1.1
smart_open==6.1.0

# Django Apps
Expand Down