Fixes adding books from list page view

This commit is contained in:
Mouse Reeve 2024-08-26 17:57:21 -07:00
parent 5879b4be5c
commit 2e15c227f3
5 changed files with 8 additions and 7 deletions

View file

@ -4,7 +4,7 @@
{% load group_tags %}
{% block modal-title %}
{% if list.curation == 'open' or request.user == list.user or list.group|is_member:request.user %}
{% if list.suggests_for or list.curation == 'open' or request.user == list.user or list.group|is_member:request.user %}
{% blocktrans trimmed with title=book|book_title %}
Add "<em>{{ title }}</em>" to this list
{% endblocktrans %}
@ -19,7 +19,7 @@
<form
name="add-book-{{ book.id }}"
method="POST"
{% if is_suggestion %}
{% if list.suggests_for %}
action="{% url 'book-add-suggestion' book_id=list.suggests_for.id %}{% if query %}?suggestion_query={{ query }}#suggestions-section{% endif %}"
{% else %}
action="{% url 'list-add-book' %}{% if query %}?q={{ query }}{% endif %}"
@ -39,7 +39,7 @@
<div class="buttons is-right is-flex-grow-1">
<button type="button" class="button" data-modal-close>{% trans "Cancel" %}</button>
<button type="submit" class="button is-link">
{% if list.curation == 'open' or request.user == list.user or list.group|is_member:request.user %}
{% if list.suggests_for or list.curation == 'open' or request.user == list.user or list.group|is_member:request.user %}
{% trans "Add" %}
{% else %}
{% trans "Suggest" %}

View file

@ -161,14 +161,13 @@
{% endif %}
{% if request.user.is_authenticated and not list.curation == 'closed' or request.user == list.user %}
<h2 class="title is-5 mt-6">
{% if list.curation == 'open' or request.user == list.user or list.group|is_member:request.user %}
{% if list.suggests_for or list.curation == 'open' or request.user == list.user or list.group|is_member:request.user %}
{% trans "Add Books" %}
{% else %}
{% trans "Suggest Books" %}
{% endif %}
</h2>
{% url 'list' list_id=list.id slug=list.name|slugify as search_url %}
{% include "lists/suggestion_search.html" with query_param="q" %}
{% include "lists/suggestion_search.html" with query_param="q" search_url=add_book_url %}
{% endif %}
<div>
<h2 class="title is-5 mt-6" id="embed-label">

View file

@ -48,7 +48,7 @@
class="button is-small is-link"
data-modal-open="{{ modal_id }}"
>
{% if list.curation == 'open' or request.user == list.user or list.group|is_member:request.user %}
{% if list.suggests_for or list.curation == 'open' or request.user == list.user or list.group|is_member:request.user %}
{% trans "Add" %}
{% else %}
{% trans "Suggest" %}

View file

@ -73,6 +73,7 @@ class List(View):
"embed_url": embed_url,
"add_failed": add_failed,
"add_succeeded": add_succeeded,
"add_book_url": reverse("list-add-book"),
}
if request.user.is_authenticated:

View file

@ -56,6 +56,7 @@ class SuggestionList(View):
"embed_url": embed_url,
"add_failed": add_failed,
"add_succeeded": add_succeeded,
"add_book_url": reverse("book-add-suggestion", args=[book_id]),
}
if request.user.is_authenticated: