Only show author confirmation if new authors are added, show suggestions for parent work and set it correctly.

This commit is contained in:
Joeri de Ruiter 2023-08-01 15:12:50 +02:00
parent 07aca2f62c
commit 220cad8661
5 changed files with 7 additions and 2 deletions

View file

@ -111,6 +111,7 @@ class EditionFromWorkForm(CustomForm):
model = models.Work
fields = [
"title",
"sort_title",
"subtitle",
"authors",
"description",

View file

@ -111,11 +111,11 @@
{% endif %}
{% endfor %}
</div>
{% else %}
{% elif add_author %}
<p class="column is-half">{% blocktrans with name=add_author %}Creating a new author: {{ name }}{% endblocktrans %}</p>
{% endif %}
{% if not book %}
{% if not book.parent_work %}
<div class="column is-half">
<fieldset>
<legend class="title is-5 mb-1">

View file

@ -10,7 +10,9 @@
{% csrf_token %}
<input type="hidden" name="last_edited_by" value="{{ request.user.id }}">
{% if form.parent_work %}
<input type="hidden" name="parent_work" value="{% firstof book.parent_work.id form.parent_work %}">
{% endif %}
<div class="columns">
<div class="column is-half">

View file

@ -58,6 +58,7 @@
<form action="{% url 'create-book-data' %}" method="POST" name="add-edition-form">
{% csrf_token %}
{{ work_form.title }}
{{ work_form.sort_title }}
{{ work_form.subtitle }}
{{ work_form.authors }}
{{ work_form.description }}

View file

@ -157,6 +157,7 @@ def add_authors(request, data):
"""helper for adding authors"""
add_author = [author for author in request.POST.getlist("add_author") if author]
if not add_author:
data["add_author"] = []
return data
data["add_author"] = add_author