Repository: bookwyrm-social/bookwyrm

Issue:
Editing an author deletes author data not in form
**Describe the bug**
Editing an author saves the form data as an update. `isni` and `viaf_id` are not part of the form, so these values are deleted when the author details are edited.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to 'author page'
2. Click on 'Edit'
3. Make a change
4. Save
5. Most users will not see any change because these values are not displayed, however they have been removed.

**Expected behavior**
Only values that have changed should change. ISNI and VIAF data should be retained on edits.

**Instance**
Development site but it presumably would be replicated on any production server.

**Additional context**
I only noticed this because I am working on a PR that will display a link to the ISNI record, and it disappears whenever I edit an author.



Editing an author deletes author data not in form
**Describe the bug**
Editing an author saves the form data as an update. `isni` and `viaf_id` are not part of the form, so these values are deleted when the author details are edited.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to 'author page'
2. Click on 'Edit'
3. Make a change
4. Save
5. Most users will not see any change because these values are not displayed, however they have been removed.

**Expected behavior**
Only values that have changed should change. ISNI and VIAF data should be retained on edits.

**Instance**
Development site but it presumably would be replicated on any production server.

**Additional context**
I only noticed this because I am working on a PR that will display a link to the ISNI record, and it disappears whenever I edit an author.





Discussion:
I probably should note here that I think I have a solution for this and will take a look, just adding this issue mostly so that I don't forget while I tidy up some other stuff.
Gah (I’ve been editing author entries regularly lately).
I don't have time to fix this before I go camping, but the reason this is happening is that I used an `exclude` fields list rather than a `fields` in the `AuthorForm` on line 201 of `bookwyrm/forms.py`. If it was an inclusive list, this wouldn't continue to happen.

I've been meaning to add a way from the UI to re-import from source (with or without overwriting existing fields), and that would help to re-populate the missing data.
I probably should note here that I think I have a solution for this and will take a look, just adding this issue mostly so that I don't forget while I tidy up some other stuff.
Gah (I’ve been editing author entries regularly lately).
I don't have time to fix this before I go camping, but the reason this is happening is that I used an `exclude` fields list rather than a `fields` in the `AuthorForm` on line 201 of `bookwyrm/forms.py`. If it was an inclusive list, this wouldn't continue to happen.

I've been meaning to add a way from the UI to re-import from source (with or without overwriting existing fields), and that would help to re-populate the missing data.

Resolving patch:
diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py
--- a/bookwyrm/forms.py
+++ b/bookwyrm/forms.py
@@ -201,12 +201,18 @@ class Meta:
 class AuthorForm(CustomForm):
     class Meta:
         model = models.Author
-        exclude = [
-            "remote_id",
-            "origin_id",
-            "created_date",
-            "updated_date",
-            "search_vector",
+        fields = [
+            "last_edited_by",
+            "name",
+            "aliases",
+            "bio",
+            "wikipedia_link",
+            "born",
+            "died",
+            "openlibrary_key",
+            "inventaire_id",
+            "librarything_key",
+            "goodreads_key",
         ]
 
 


Test patch: