mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Preserve search results after adding a book
This commit is contained in:
parent
ef83eb33b0
commit
0cb80aeb55
2 changed files with 5 additions and 2 deletions
|
@ -116,7 +116,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<p>{% include 'snippets/book_titleby.html' with book=book %}</p>
|
<p>{% include 'snippets/book_titleby.html' with book=book %}</p>
|
||||||
<form name="add-book" method="post" action="{% url 'list-add-book' %}">
|
<form name="add-book" method="post" action="{% url 'list-add-book' %}{% if query %}?q={{ query }}{% endif %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="hidden" name="book" value="{{ book.id }}">
|
<input type="hidden" name="book" value="{{ book.id }}">
|
||||||
<input type="hidden" name="list" value="{{ list.id }}">
|
<input type="hidden" name="list" value="{{ list.id }}">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
""" book list views"""
|
""" book list views"""
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
|
@ -9,6 +10,7 @@ from django.db.models.functions import Coalesce
|
||||||
from django.http import HttpResponseNotFound, HttpResponseBadRequest, HttpResponse
|
from django.http import HttpResponseNotFound, HttpResponseBadRequest, HttpResponse
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
|
from django.urls import reverse
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from django.views.decorators.http import require_POST
|
from django.views.decorators.http import require_POST
|
||||||
|
@ -263,7 +265,8 @@ def add_book(request):
|
||||||
# if the book is already on the list, don't flip out
|
# if the book is already on the list, don't flip out
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return redirect("list", book_list.id)
|
path = reverse('list', args=[book_list.id])
|
||||||
|
return redirect("{:s}?{:s}".format(path, urlencode(request.GET)))
|
||||||
|
|
||||||
|
|
||||||
@require_POST
|
@require_POST
|
||||||
|
|
Loading…
Reference in a new issue