Skip to content

Commit

Permalink
[Fixes #9862] Thesaurus label are not available with default language (
Browse files Browse the repository at this point in the history
…#9864) (#9904)

* [Fixes #9861]Cannot open metadata detail with thesaurus installed

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

Co-authored-by: Giovanni Allegri <giohappy@gmail.com>
Co-authored-by: Alessio Fabiani <alessio.fabiani@geosolutionsgroup.com>

Co-authored-by: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com>
Co-authored-by: Giovanni Allegri <giohappy@gmail.com>
Co-authored-by: Alessio Fabiani <alessio.fabiani@geosolutionsgroup.com>
  • Loading branch information
4 people authored Aug 24, 2022
1 parent 939b13e commit f941aa5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
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

0 comments on commit f941aa5

Please sign in to comment.