New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redirect to collection listing after editing/deleting an item from it #7810
Conversation
Manage this branch in SquashTest this branch here: https://tijani-diafeaturecollection-re-t7n7q.squash.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! A few bits to consider - also, we lose the information when following the edit -> delete -> listing path
wagtail/documents/views/documents.py
Outdated
edit_url = reverse('wagtaildocs:edit', args=(doc.id,)) | ||
redirect_url = 'wagtaildocs:index' | ||
if next_url: | ||
edit_url += "?" + urlencode({"next": next_url}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: You can probably use an f-string or similar instead of concatenation here
wagtail/images/views/images.py
Outdated
collection_id = self.request.GET.get('collection_id') | ||
if collection_id: | ||
try: | ||
self.current_collection = Collection.objects.get(id=collection_id) | ||
images = images.filter(collection=self.current_collection) | ||
next_url = reverse('wagtailimages:index') + "?" + urlencode({"collection_id": collection_id}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this? Shouldn't we just use the current url, so we get tags (for instance) as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I've updated it to use the current url so we don't lose information.
d176101
to
1e14fe0
Compare
545ebd9
to
e4ab9e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! LGTM
Merged in bafb435 |
When a user selects a collection to browse in the admin and opens a file to make some changes to it, on save, the admin browser defaults back to a default view of documents/images instead of staying on the collection and the page of the collection the users was on when they clicked on the file to make changes.
The goal of this PR is to make the view remember the collection users were exploring before editing one item from that collection.