From ef585acb4ef200117e83ab4e18a5685f5232b337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20I=C3=9Fbr=C3=BCcker?= Date: Tue, 26 Sep 2023 09:06:14 +0200 Subject: [PATCH] Fix bulk edit to respect searched tags (#537) --- bookmarks/templates/bookmarks/archive.html | 2 +- bookmarks/templates/bookmarks/index.html | 2 +- bookmarks/templates/bookmarks/shared.html | 2 +- bookmarks/tests/test_bookmark_archived_view.py | 10 ++++++++++ bookmarks/tests/test_bookmark_index_view.py | 10 ++++++++++ bookmarks/tests/test_bookmark_shared_view.py | 14 ++++++++++++-- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/bookmarks/templates/bookmarks/archive.html b/bookmarks/templates/bookmarks/archive.html index 80eaed47..c2d83fe1 100644 --- a/bookmarks/templates/bookmarks/archive.html +++ b/bookmarks/templates/bookmarks/archive.html @@ -20,7 +20,7 @@

Archived bookmarks

-
{% csrf_token %} {% include 'bookmarks/bulk_edit/bar.html' with disable_actions='bulk_archive' %} diff --git a/bookmarks/templates/bookmarks/index.html b/bookmarks/templates/bookmarks/index.html index b0dde736..59e65b00 100644 --- a/bookmarks/templates/bookmarks/index.html +++ b/bookmarks/templates/bookmarks/index.html @@ -20,7 +20,7 @@

Bookmarks

- {% csrf_token %} {% include 'bookmarks/bulk_edit/bar.html' with disable_actions='bulk_unarchive' %} diff --git a/bookmarks/templates/bookmarks/shared.html b/bookmarks/templates/bookmarks/shared.html index 7332aaab..81811f78 100644 --- a/bookmarks/templates/bookmarks/shared.html +++ b/bookmarks/templates/bookmarks/shared.html @@ -16,7 +16,7 @@

Shared bookmarks

{% bookmark_search bookmark_list.filters tag_cloud.tags mode='shared' %} - {% csrf_token %} diff --git a/bookmarks/tests/test_bookmark_archived_view.py b/bookmarks/tests/test_bookmark_archived_view.py index 1ba10d75..6f70d329 100644 --- a/bookmarks/tests/test_bookmark_archived_view.py +++ b/bookmarks/tests/test_bookmark_archived_view.py @@ -256,3 +256,13 @@ def test_allowed_bulk_actions_with_sharing_enabled(self): ''', html) + + def test_url_encode_bookmark_actions_url(self): + url = reverse('bookmarks:archived') + '?q=%23foo' + response = self.client.get(url) + html = response.content.decode() + soup = self.make_soup(html) + actions_form = soup.select('form.bookmark-actions')[0] + + self.assertEqual(actions_form.attrs['action'], + '/bookmarks/archived/action?q=%23foo&return_url=%2Fbookmarks%2Farchived%3Fq%3D%2523foo') diff --git a/bookmarks/tests/test_bookmark_index_view.py b/bookmarks/tests/test_bookmark_index_view.py index 11856761..d3192db3 100644 --- a/bookmarks/tests/test_bookmark_index_view.py +++ b/bookmarks/tests/test_bookmark_index_view.py @@ -282,3 +282,13 @@ def test_allowed_bulk_actions_with_sharing_enabled(self): ''', html) + + def test_url_encode_bookmark_actions_url(self): + url = reverse('bookmarks:index') + '?q=%23foo' + response = self.client.get(url) + html = response.content.decode() + soup = self.make_soup(html) + actions_form = soup.select('form.bookmark-actions')[0] + + self.assertEqual(actions_form.attrs['action'], + '/bookmarks/action?q=%23foo&return_url=%2Fbookmarks%3Fq%3D%2523foo') diff --git a/bookmarks/tests/test_bookmark_shared_view.py b/bookmarks/tests/test_bookmark_shared_view.py index 76e72245..c8e1731b 100644 --- a/bookmarks/tests/test_bookmark_shared_view.py +++ b/bookmarks/tests/test_bookmark_shared_view.py @@ -5,10 +5,10 @@ from django.urls import reverse from bookmarks.models import Bookmark, Tag, UserProfile -from bookmarks.tests.helpers import BookmarkFactoryMixin, collapse_whitespace +from bookmarks.tests.helpers import BookmarkFactoryMixin, collapse_whitespace, HtmlTestMixin -class BookmarkSharedViewTestCase(TestCase, BookmarkFactoryMixin): +class BookmarkSharedViewTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin): def authenticate(self) -> None: user = self.get_or_create_test_user() @@ -334,3 +334,13 @@ def test_should_open_bookmarks_in_same_page_if_specified_in_user_profile(self): response = self.client.get(reverse('bookmarks:shared')) self.assertVisibleBookmarks(response, visible_bookmarks, '_self') + + def test_url_encode_bookmark_actions_url(self): + url = reverse('bookmarks:shared') + '?q=%23foo' + response = self.client.get(url) + html = response.content.decode() + soup = self.make_soup(html) + actions_form = soup.select('form.bookmark-actions')[0] + + self.assertEqual(actions_form.attrs['action'], + '/bookmarks/shared/action?q=%23foo&return_url=%2Fbookmarks%2Fshared%3Fq%3D%2523foo')