Skip to content

Commit

Permalink
Test + just use reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
rtpg committed Nov 4, 2024
1 parent 8bf6021 commit 9163b08
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changelog

* Add an admin command to remove orphaned tags
* Remove support for Python 3.8
* Replace `request.get_full_path()` with `request.path` for merge form action
* Fix an issue where the admin merge tag form redirect would fail when querystrings are present inside the URL

6.1.0 (2024-09-29)
~~~~~~~~~~~~~~~~~~
Expand Down
5 changes: 2 additions & 3 deletions taggit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ def render_tag_form(self, request, queryset):
self.message_user(request, "Please select at least one tag.")
return redirect(request.get_full_path())

# set the selected tags into the session, to be used later
selected_tag_ids = ",".join(selected)
redirect_url = f"{request.path}merge-tags/"

request.session["selected_tag_ids"] = selected_tag_ids

return redirect(redirect_url)
return redirect("admin:taggit_tag_merge_tags")

def merge_tags_view(self, request):
selected_tag_ids = request.session.get("selected_tag_ids", "").split(",")
Expand Down
1 change: 1 addition & 0 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def test_tag_merging(self):
)
# we're redirecting
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse("admin:taggit_tag_merge_tags"))
# make sure what we expected got into the session keys
assert "selected_tag_ids" in self.client.session.keys()
self.assertEqual(
Expand Down

0 comments on commit 9163b08

Please sign in to comment.