Skip to content

Commit 0370a6d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2b2e593 commit 0370a6d

File tree

3 files changed

+65
-31
lines changed

3 files changed

+65
-31
lines changed

openlibrary/i18n/messages.pot

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,11 @@ msgid "Name"
706706
msgstr ""
707707

708708
#: subjects.html
709-
msgid "Edit Subject Tag"
709+
msgid "Edit tag for this subject"
710+
msgstr ""
711+
712+
#: subjects.html
713+
msgid "Create tag for this subject"
710714
msgstr ""
711715

712716
#: subjects.html
@@ -725,6 +729,10 @@ msgstr[1] ""
725729
msgid "Search for books with subject %(name)s."
726730
msgstr ""
727731

732+
#: subjects.html
733+
msgid "Disambiguations"
734+
msgstr ""
735+
728736
#: support.html
729737
msgid "How can we help?"
730738
msgstr ""
@@ -786,7 +794,7 @@ msgstr ""
786794
#: CreateListModal.html EditButtons.html account/notifications.html
787795
#: account/password/reset.html account/privacy.html admin/imports-add.html
788796
#: admin/permissions.html books/add.html databarEdit.html merge/authors.html
789-
#: my_books/dropdown_content.html support.html tag/add.html
797+
#: my_books/dropdown_content.html support.html type/tag/form.html
790798
msgid "Cancel"
791799
msgstr ""
792800

@@ -1987,7 +1995,7 @@ msgid "Imports"
19871995
msgstr ""
19881996

19891997
#: admin/imports-add.html books/add.html books/edit/edition.html
1990-
#: books/edit/excerpts.html covers/change.html tag/add.html
1998+
#: books/edit/excerpts.html covers/change.html type/tag/form.html
19911999
msgid "Add"
19922000
msgstr ""
19932001

@@ -3165,7 +3173,7 @@ msgstr ""
31653173
msgid "Add a book to Open Library"
31663174
msgstr ""
31673175

3168-
#: books/add.html tag/add.html
3176+
#: books/add.html
31693177
msgid ""
31703178
"We require a minimum set of fields to create a new record. These are "
31713179
"those fields."
@@ -3263,7 +3271,7 @@ msgstr ""
32633271
msgid "Only fill this out if this is a web book"
32643272
msgstr ""
32653273

3266-
#: EditButtons.html books/add.html tag/add.html
3274+
#: EditButtons.html books/add.html type/tag/form.html
32673275
msgid ""
32683276
"By saving a change to this wiki, you agree that your contribution is "
32693277
"given freely to the world under <a "
@@ -6249,18 +6257,6 @@ msgstr ""
62496257
msgid "OpenAPI"
62506258
msgstr ""
62516259

6252-
#: tag/add.html
6253-
msgid "Add a tag"
6254-
msgstr ""
6255-
6256-
#: tag/add.html
6257-
msgid "Add a tag to Open Library"
6258-
msgstr ""
6259-
6260-
#: tag/add.html
6261-
msgid "Add this tag now"
6262-
msgstr ""
6263-
62646260
#: type/about/edit.html type/page/edit.html type/permission/edit.html
62656261
#: type/template/edit.html type/usergroup/edit.html
62666262
#, python-format
@@ -6890,8 +6886,24 @@ msgstr ""
68906886
msgid "Writers"
68916887
msgstr ""
68926888

6893-
#: type/tag/edit.html
6894-
msgid "Edit Tag"
6889+
#: type/tag/form.html
6890+
msgid "Edit tag"
6891+
msgstr ""
6892+
6893+
#: type/tag/form.html
6894+
msgid "Add a tag"
6895+
msgstr ""
6896+
6897+
#: type/tag/form.html
6898+
msgid "Add a tag to Open Library"
6899+
msgstr ""
6900+
6901+
#: type/tag/form.html
6902+
msgid "We require a minimum set of fields to create a new collection tag."
6903+
msgstr ""
6904+
6905+
#: type/tag/form.html
6906+
msgid "Add this tag now"
68956907
msgstr ""
68966908

68976909
#: type/tag/tag_form_inputs.html
@@ -6902,10 +6914,27 @@ msgstr ""
69026914
msgid "Tag Description"
69036915
msgstr ""
69046916

6917+
#: type/tag/tag_form_inputs.html
6918+
msgid "Page Body"
6919+
msgstr ""
6920+
69056921
#: type/tag/tag_form_inputs.html
69066922
msgid "Tag type"
69076923
msgstr ""
69086924

6925+
#: type/tag/view.html
6926+
#, python-format
6927+
msgid "<strong>Type:</strong> %(tag_type)s"
6928+
msgstr ""
6929+
6930+
#: type/tag/view.html type/user/edit.html
6931+
msgid "Description"
6932+
msgstr ""
6933+
6934+
#: type/tag/view.html
6935+
msgid "Tag Body"
6936+
msgstr ""
6937+
69096938
#: type/tag/view.html
69106939
#, python-format
69116940
msgid "View subject page for %(name)s."
@@ -6956,10 +6985,6 @@ msgstr ""
69566985
msgid "Display Name"
69576986
msgstr ""
69586987

6959-
#: type/user/edit.html
6960-
msgid "Description"
6961-
msgstr ""
6962-
69636988
#: type/user/view.html
69646989
msgid "admin page"
69656990
msgstr ""

openlibrary/plugins/upstream/addtag.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ def get_subject_tag_types():
2929

3030

3131
def validate_tag(tag):
32-
return tag.get('name', '') and tag.get('tag_type', '') in get_tag_types() and tag.get('body')
32+
return (
33+
tag.get('name', '')
34+
and tag.get('tag_type', '') in get_tag_types()
35+
and tag.get('body')
36+
)
3337

3438

3539
def validate_subject_tag(tag):
@@ -67,7 +71,7 @@ def find_match(name: str, tag_type: str) -> str:
6771
Tries to find an existing tag that matches the data provided by the user.
6872
Returns the key of the matching tag, or an empty string if no such tag exists.
6973
"""
70-
matches = Tag.find(name, tag_type=tag_type)
74+
matches = Tag.find(name, tag_type=tag_type)
7175
return matches[0] if matches else ''
7276

7377

@@ -121,7 +125,7 @@ def POST(self):
121125
# A tag with the same name and type already exists
122126
add_flash_message(
123127
'error',
124-
f'A matching tag with the same name and type already exists: <a href="{match}">{match}</a>'
128+
f'A matching tag with the same name and type already exists: <a href="{match}">{match}</a>',
125129
)
126130
return render_template('type/tag/form', i)
127131

@@ -172,7 +176,7 @@ def POST(self, key):
172176
# A tag with the same name and type already exists
173177
add_flash_message(
174178
'error',
175-
f'A matching tag with the same name and type already exists: <a href="{match}">{match}</a>'
179+
f'A matching tag with the same name and type already exists: <a href="{match}">{match}</a>',
176180
)
177181
return render_template("type/tag/form", formdata, redirect=i.redir)
178182

openlibrary/plugins/worksearch/subjects.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,23 @@ def normalize_key(self, key):
6060
return key
6161

6262
def decorate_with_tags(self, subject) -> None:
63-
tag_keys = Tag.find(subject.name)
64-
if tag_keys:
63+
if tag_keys := Tag.find(subject.name):
6564
tags = web.ctx.site.get_many(tag_keys)
6665
subject.disambiguations = tags
6766

68-
if filtered_tags := [tag for tag in tags if tag.tag_type == subject.subject_type]:
67+
if filtered_tags := [
68+
tag for tag in tags if tag.tag_type == subject.subject_type
69+
]:
6970
subject.tag = filtered_tags[0]
7071
# Remove matching subject tag from disambiguated tags:
7172
subject.disambiguations = list(set(tags) - set([subject.tag]))
7273

7374
for tag in subject.disambiguations:
74-
tag.subject_key = f"/subjects/{tag.name}" if tag.tag_type == "subject" else f"/subjects/{tag.tag_type}:{tag.name}"
75+
tag.subject_key = (
76+
f"/subjects/{tag.name}"
77+
if tag.tag_type == "subject"
78+
else f"/subjects/{tag.tag_type}:{tag.name}"
79+
)
7580

7681

7782
class subjects_json(delegate.page):

0 commit comments

Comments
 (0)