mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-24 00:50:35 +00:00
Add books to lists from the book page
This commit is contained in:
parent
6e6417cb91
commit
f0a936f15e
4 changed files with 27 additions and 6 deletions
|
@ -233,7 +233,7 @@
|
|||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if lists.exists %}
|
||||
{% if lists.exists or request.user.list_set.exists %}
|
||||
<section class="content block">
|
||||
<h2 class="title is-5">{% trans "Lists" %}</h2>
|
||||
<ul>
|
||||
|
@ -241,6 +241,26 @@
|
|||
<li><a href="{{ list.local_path }}">{{ list.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% if request.user.list_set.exists %}
|
||||
<form name="list-add" method="post" action="{% url 'list-add-book' %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<label class="label" for="id_list">{% trans "Add to list" %}</label>
|
||||
<div class="field has-addons">
|
||||
<div class="select control">
|
||||
<select name="list" id="id_list">
|
||||
{% for list in user.list_set.all %}
|
||||
<option value="{{ list.id }}">{{ list.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button type="submit" class="button is-link">{% trans "Add" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -83,9 +83,10 @@
|
|||
</div>
|
||||
<div class="column">
|
||||
<p>{% include 'snippets/book_titleby.html' with book=book %}</p>
|
||||
<form name="add-book" method="post" action="{% url 'list-add-book' list.id %}">
|
||||
<form name="add-book" method="post" action="{% url 'list-add-book' %}">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ book.id }}">
|
||||
<input type="hidden" name="list" value="{{ list.id }}">
|
||||
<button type="submit" class="button is-small is-link">{% if list.curation == 'open' or request.user == list.user %}{% trans "Add" %}{% else %}{% trans "Suggest" %}{% endif %}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -118,7 +118,7 @@ urlpatterns = [
|
|||
re_path(r"^list/?$", views.Lists.as_view(), name="lists"),
|
||||
re_path(r"^list/(?P<list_id>\d+)(.json)?/?$", views.List.as_view(), name="list"),
|
||||
re_path(
|
||||
r"^list/(?P<list_id>\d+)/add/?$", views.list.add_book, name="list-add-book"
|
||||
r"^list/add-book/?$", views.list.add_book, name="list-add-book"
|
||||
),
|
||||
re_path(
|
||||
r"^list/(?P<list_id>\d+)/remove/?$",
|
||||
|
|
|
@ -173,9 +173,9 @@ class Curate(View):
|
|||
|
||||
|
||||
@require_POST
|
||||
def add_book(request, list_id):
|
||||
def add_book(request):
|
||||
""" put a book on a list """
|
||||
book_list = get_object_or_404(models.List, id=list_id)
|
||||
book_list = get_object_or_404(models.List, id=request.POST.get('list'))
|
||||
if not object_visible_to_user(request.user, book_list):
|
||||
return HttpResponseNotFound()
|
||||
|
||||
|
@ -204,7 +204,7 @@ def add_book(request, list_id):
|
|||
# if the book is already on the list, don't flip out
|
||||
pass
|
||||
|
||||
return redirect("list", list_id)
|
||||
return redirect("list", book_list.id)
|
||||
|
||||
|
||||
@require_POST
|
||||
|
|
Loading…
Reference in a new issue