From f2800efc1a3ccb32563ddead27005822d7254c4b Mon Sep 17 00:00:00 2001 From: Bastian Date: Sat, 17 May 2025 10:13:07 +0200 Subject: [PATCH] Allow pre-filling tags in new bookmark form (#1060) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat - Allow tag_string as query for BookmarkForm in order to set tags via bookmark snippets * add test --------- Co-authored-by: Sascha Ißbrücker --- bookmarks/forms.py | 1 + bookmarks/tests/test_bookmark_new_view.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/bookmarks/forms.py b/bookmarks/forms.py index 3d3db88..bdd15c0 100644 --- a/bookmarks/forms.py +++ b/bookmarks/forms.py @@ -41,6 +41,7 @@ class BookmarkForm(forms.ModelForm): "title": request.GET.get("title"), "description": request.GET.get("description"), "notes": request.GET.get("notes"), + "tag_string": request.GET.get("tags"), "auto_close": "auto_close" in request.GET, "unread": request.user_profile.default_mark_unread, } diff --git a/bookmarks/tests/test_bookmark_new_view.py b/bookmarks/tests/test_bookmark_new_view.py index eb80f4b..5e73d83 100644 --- a/bookmarks/tests/test_bookmark_new_view.py +++ b/bookmarks/tests/test_bookmark_new_view.py @@ -110,6 +110,19 @@ class BookmarkNewViewTestCase(TestCase, BookmarkFactoryMixin): html, ) + def test_should_prefill_tags_from_url_parameter(self): + response = self.client.get( + reverse("linkding:bookmarks.new") + "?tags=tag1%20tag2%20tag3" + ) + html = response.content.decode() + + self.assertInHTML( + '', + html, + ) + def test_should_prefill_notes_from_url_parameter(self): response = self.client.get( reverse("linkding:bookmarks.new")