From 6ac38564e2c47f73df2f949ac6060c06ce167dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20C=C3=A1mara?= Date: Sat, 3 Feb 2024 22:55:33 +0000 Subject: [PATCH 1/3] Add wikidata field for authors --- bookwyrm/forms/author.py | 2 ++ bookwyrm/models/author.py | 3 +++ bookwyrm/tests/data/user_import.json | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bookwyrm/forms/author.py b/bookwyrm/forms/author.py index 5b54a07b5..a3a759af7 100644 --- a/bookwyrm/forms/author.py +++ b/bookwyrm/forms/author.py @@ -15,6 +15,7 @@ class AuthorForm(CustomForm): "aliases", "bio", "wikipedia_link", + "wikidata", "website", "born", "died", @@ -32,6 +33,7 @@ class AuthorForm(CustomForm): "wikipedia_link": forms.TextInput( attrs={"aria-describedby": "desc_wikipedia_link"} ), + "wikidata": forms.TextInput(attrs={"aria-describedby": "desc_wikidata"}), "website": forms.TextInput(attrs={"aria-describedby": "desc_website"}), "born": forms.SelectDateWidget(attrs={"aria-describedby": "desc_born"}), "died": forms.SelectDateWidget(attrs={"aria-describedby": "desc_died"}), diff --git a/bookwyrm/models/author.py b/bookwyrm/models/author.py index 981e3c0cc..b32d49d54 100644 --- a/bookwyrm/models/author.py +++ b/bookwyrm/models/author.py @@ -18,6 +18,9 @@ class Author(BookDataModel): wikipedia_link = fields.CharField( max_length=255, blank=True, null=True, deduplication_field=True ) + wikidata = fields.CharField( + max_length=255, blank=True, null=True, deduplication_field=True + ) isni = fields.CharField( max_length=255, blank=True, null=True, deduplication_field=True ) diff --git a/bookwyrm/tests/data/user_import.json b/bookwyrm/tests/data/user_import.json index 0318ddfeb..ffe2e7d9e 100644 --- a/bookwyrm/tests/data/user_import.json +++ b/bookwyrm/tests/data/user_import.json @@ -136,6 +136,7 @@ ], "bio": "

American political scientist and anthropologist

", "wikipediaLink": "https://en.wikipedia.org/wiki/James_C._Scott", + "wikidata": "Q3025403", "website": "", "@context": "https://www.w3.org/ns/activitystreams" } @@ -320,6 +321,7 @@ "aliases": [], "bio": "", "wikipediaLink": "", + "wikidata": "", "website": "", "@context": "https://www.w3.org/ns/activitystreams" } @@ -396,4 +398,4 @@ "https://your.domain.here/user/rat" ], "blocks": ["https://your.domain.here/user/badger"] -} \ No newline at end of file +} From 89d8537e1bd3d2daa3cd1fbc6d989a5d4be56220 Mon Sep 17 00:00:00 2001 From: Carlos Camara Date: Mon, 5 Feb 2024 22:08:34 +0000 Subject: [PATCH 2/3] Add wikidata field to author's template --- bookwyrm/templates/author/edit_author.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bookwyrm/templates/author/edit_author.html b/bookwyrm/templates/author/edit_author.html index 12ddc4d28..f3e908c9b 100644 --- a/bookwyrm/templates/author/edit_author.html +++ b/bookwyrm/templates/author/edit_author.html @@ -55,6 +55,8 @@

{{ form.wikipedia_link }}

+

{{ form.wikidata }}

+ {% include 'snippets/form_errors.html' with errors_list=form.wikipedia_link.errors id="desc_wikipedia_link" %}

{{ form.website }}

From a914a44fba28defec6fefcbf90deee828176ddf5 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 23 Mar 2024 07:54:54 -0700 Subject: [PATCH 3/3] Removes unnecessary redeclaration of wikidata model field in Author --- bookwyrm/models/author.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/bookwyrm/models/author.py b/bookwyrm/models/author.py index b32d49d54..981e3c0cc 100644 --- a/bookwyrm/models/author.py +++ b/bookwyrm/models/author.py @@ -18,9 +18,6 @@ class Author(BookDataModel): wikipedia_link = fields.CharField( max_length=255, blank=True, null=True, deduplication_field=True ) - wikidata = fields.CharField( - max_length=255, blank=True, null=True, deduplication_field=True - ) isni = fields.CharField( max_length=255, blank=True, null=True, deduplication_field=True )