Skip to content

Commit

Permalink
subjects: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yashlamba authored and 0einstein0 committed Aug 15, 2024
1 parent 88e26a5 commit aaf4e15
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion invenio_vocabularies/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"funders",
"subjects",
]
"""Configure CUSTOM_VOCABULARY_TYPES to differentiate output. Is used in VocabulariesServiceConfig."""
"""List of custom vocabulary types."""

VOCABULARIES_DATASTREAM_READERS = {
"csv": CSVReader,
Expand Down
2 changes: 1 addition & 1 deletion invenio_vocabularies/contrib/subjects/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SubjectsSearchOptions(SearchOptions):
),
"subject": dict(
title=_("Name"),
fields=["indexed_at"],
fields=["subject_sort"],
),
"newest": dict(
title=_("Newest"),
Expand Down
6 changes: 2 additions & 4 deletions invenio_vocabularies/contrib/subjects/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@

"""Subjects schema."""

from functools import partial

from flask import current_app
from invenio_i18n import lazy_gettext as _
from invenio_i18n import get_locale
from marshmallow import fields, pre_load
from marshmallow_utils.fields import SanitizedUnicode

Expand All @@ -39,7 +37,7 @@ class SubjectSchema(BaseVocabularySchema):
@pre_load
def add_subject_from_title(self, data, **kwargs):
"""Add subject from title if not present."""
locale = current_app.config.get("BABEL_DEFAULT_LOCALE", "en")
locale = get_locale().language
if "subject" not in data:
data["subject"] = data["title"].get(locale) or data["title"].values()[0]
return data
Expand Down

0 comments on commit aaf4e15

Please sign in to comment.