diff --git a/bookwyrm/tests/test_view_actions.py b/bookwyrm/tests/test_view_actions.py index 5066735db..e97512cea 100644 --- a/bookwyrm/tests/test_view_actions.py +++ b/bookwyrm/tests/test_view_actions.py @@ -360,6 +360,22 @@ class ViewActions(TestCase): self.assertEqual(resp.template_name, 'edit_author.html') + def test_edit_shelf(self): + ''' set name or privacy on shelf ''' + shelf = self.local_user.shelf_set.get(identifier='to-read') + self.assertEqual(shelf.privacy, 'public') + + request = self.factory.post( + '', { + 'privacy': 'unlisted', + 'user': self.local_user.id, + }) + request.user = self.local_user + actions.edit_shelf(request, shelf.id) + + self.assertEqual(shelf.privacy, 'unlisted') + + def test_edit_readthrough(self): ''' adding dates to an ongoing readthrough ''' start = timezone.make_aware(dateutil.parser.parse('2021-01-03')) diff --git a/bookwyrm/view_actions.py b/bookwyrm/view_actions.py index 3de1dd9d7..f1af60ee5 100644 --- a/bookwyrm/view_actions.py +++ b/bookwyrm/view_actions.py @@ -355,10 +355,9 @@ def edit_shelf(request, shelf_id): form = forms.ShelfForm(request.POST, instance=shelf) if not form.is_valid(): - return redirect(request.headers.get('Referer', '/')) + return redirect(shelf.local_path) shelf = form.save() - return redirect('/user/%s/shelf/%s' % \ - (request.user.localname, shelf.identifier)) + return redirect(shelf.local_path) @login_required