From a8483754c33b1c6fa8952d9b766f8a6167de247e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 11 Jan 2021 20:21:32 -0800 Subject: [PATCH] Fixes edit book view --- bookwyrm/forms.py | 1 + bookwyrm/templatetags/bookwyrm_tags.py | 1 + bookwyrm/tests/test_view_actions.py | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index 152c2d76..eafbe407 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -125,6 +125,7 @@ class EditionForm(CustomForm): 'origin_id', 'created_date', 'updated_date', + 'edition_rank', 'authors',# TODO 'parent_work', diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index ef8e0033..d774a079 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -149,6 +149,7 @@ def get_mentions(status, user): @register.filter(name='status_preview_name') def get_status_preview_name(obj): + ''' text snippet with book context for a status ''' name = obj.__class__.__name__.lower() if name == 'review': return '%s of %s' % (name, obj.book.title) diff --git a/bookwyrm/tests/test_view_actions.py b/bookwyrm/tests/test_view_actions.py index 3547f39c..30549bf2 100644 --- a/bookwyrm/tests/test_view_actions.py +++ b/bookwyrm/tests/test_view_actions.py @@ -291,6 +291,20 @@ class ViewActions(TestCase): self.assertEqual(self.local_user.name, 'New Name') + def test_edit_book(self): + ''' lets a user edit a book ''' + self.local_user.groups.add(self.group) + form = forms.EditionForm(instance=self.book) + form.data['title'] = 'New Title' + form.data['last_edited_by'] = self.local_user.id + request = self.factory.post('', form.data) + request.user = self.local_user + with patch('bookwyrm.broadcast.broadcast_task.delay'): + actions.edit_book(request, self.book.id) + self.book.refresh_from_db() + self.assertEqual(self.book.title, 'New Title') + + def test_switch_edition(self): ''' updates user's relationships to a book ''' work = models.Work.objects.create(title='test work')