diff --git a/openlibrary/i18n/messages.pot b/openlibrary/i18n/messages.pot index e696842ebe78..3510e1634348 100644 --- a/openlibrary/i18n/messages.pot +++ b/openlibrary/i18n/messages.pot @@ -37,8 +37,8 @@ msgstr "" #: account.html check_ins/check_in_prompt.html #: check_ins/reading_goal_progress.html databarHistory.html -#: databarTemplate.html databarView.html subjects.html -#: type/edition/compact_title.html type/user/view.html +#: databarTemplate.html databarView.html type/edition/compact_title.html +#: type/user/view.html msgid "Edit" msgstr "" @@ -706,7 +706,11 @@ msgid "Name" msgstr "" #: subjects.html -msgid "Edit Subject Tag" +msgid "Tag" +msgstr "" + +#: subjects.html +msgid "Link this subject to a tag" msgstr "" #: subjects.html @@ -787,6 +791,7 @@ msgstr "" #: account/password/reset.html account/privacy.html admin/imports-add.html #: admin/permissions.html books/add.html databarEdit.html merge/authors.html #: my_books/dropdown_content.html support.html tag/add.html +#: type/tag/collection/edit.html type/tag/subject/edit.html msgid "Cancel" msgstr "" @@ -1988,6 +1993,7 @@ msgstr "" #: admin/imports-add.html books/add.html books/edit/edition.html #: books/edit/excerpts.html covers/change.html tag/add.html +#: type/tag/collection/edit.html type/tag/subject/edit.html msgid "Add" msgstr "" @@ -3263,7 +3269,8 @@ msgstr "" msgid "Only fill this out if this is a web book" msgstr "" -#: EditButtons.html books/add.html tag/add.html +#: EditButtons.html books/add.html tag/add.html type/tag/collection/edit.html +#: type/tag/subject/edit.html msgid "" "By saving a change to this wiki, you agree that your contribution is " "given freely to the world under module.initTagTypeSelector(tagTypeSelector)) } }); diff --git a/openlibrary/plugins/openlibrary/js/tag-form.js b/openlibrary/plugins/openlibrary/js/tag-form.js index f26ec1f2a76f..3e86480eda5c 100644 --- a/openlibrary/plugins/openlibrary/js/tag-form.js +++ b/openlibrary/plugins/openlibrary/js/tag-form.js @@ -1,16 +1,16 @@ -const SUBJECT_TYPES = ["subject", "person", "place", "time"] +const SUBJECT_TYPES = ['subject', 'person', 'place', 'time'] let inputContainer const inputSetMapping = {} export function initTagTypeSelector(selector) { - const subTypeInputs = document.querySelectorAll(".sub-type-inputs__input-set") - inputContainer = document.querySelector(".sub-type-inputs") + const subTypeInputs = document.querySelectorAll('.sub-type-inputs__input-set') + inputContainer = document.querySelector('.sub-type-inputs') subTypeInputs.forEach((input) => { inputSetMapping[input.dataset.inputType] = input }) - inputContainer.textContent = "" + inputContainer.textContent = '' if (selector.value) { if (SUBJECT_TYPES.includes(selector.value)) { @@ -20,7 +20,7 @@ export function initTagTypeSelector(selector) { } } - selector.addEventListener("change", (event) => { + selector.addEventListener('change', (event) => { const selectedValue = event.target.value let selectedType if (SUBJECT_TYPES.includes(selectedValue)) { @@ -37,7 +37,7 @@ export function initTagTypeSelector(selector) { } function hideSubTypeInputs() { - inputContainer.textContent = "" + inputContainer.textContent = '' } function showSubTypeInputs(inputsToShow) { diff --git a/openlibrary/plugins/upstream/addtag.py b/openlibrary/plugins/upstream/addtag.py index d9b3289c584f..d1b175ef24fc 100644 --- a/openlibrary/plugins/upstream/addtag.py +++ b/openlibrary/plugins/upstream/addtag.py @@ -35,7 +35,11 @@ def validate_tag(tag): def validate_subject_tag(tag): - return tag.get('name', '') and tag.get('tag_type', '') in get_subject_tag_types() and tag.get('body') + return ( + tag.get('name', '') + and tag.get('tag_type', '') in get_subject_tag_types() + and tag.get('body') + ) def create_tag(tag: dict) -> Tag: @@ -123,7 +127,7 @@ def find_match(self, i: web.utils.Storage): """ Tries to find an existing tag that matches the data provided by the user. """ - matches = Tag.find(i.name, tag_type=i.tag_type) + matches = Tag.find(i.name, tag_type=i.tag_type) return matches[0] if matches else None def tag_match(self, match: list) -> NoReturn: diff --git a/openlibrary/plugins/worksearch/subjects.py b/openlibrary/plugins/worksearch/subjects.py index bebe180ca6e5..dfa78885eb78 100644 --- a/openlibrary/plugins/worksearch/subjects.py +++ b/openlibrary/plugins/worksearch/subjects.py @@ -61,12 +61,13 @@ def normalize_key(self, key): return key def decorate_with_tags(self, subject) -> None: - tag_keys = Tag.find(subject.name) - if tag_keys: + if tag_keys := Tag.find(subject.name): tags = web.ctx.site.get_many(tag_keys) subject.disambiguations = tags - if filtered_tags := [tag for tag in tags if tag.tag_type == subject.subject_type]: + if filtered_tags := [ + tag for tag in tags if tag.tag_type == subject.subject_type + ]: subject.tag = filtered_tags[0]