Fixes subjects in add edition view

This commit is contained in:
Mouse Reeve 2022-03-17 08:02:59 -07:00
parent 26f0501e2f
commit a684d86d15
3 changed files with 13 additions and 2 deletions

View file

@ -86,7 +86,6 @@ class EditionForm(CustomForm):
"ASIN": forms.TextInput(attrs={"aria-describedby": "desc_ASIN"}), "ASIN": forms.TextInput(attrs={"aria-describedby": "desc_ASIN"}),
} }
class EditionFromWorkForm(CustomForm): class EditionFromWorkForm(CustomForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)

View file

@ -57,7 +57,18 @@
<form action="{% url 'create-book-data' %}" method="POST" name="add-edition-form"> <form action="{% url 'create-book-data' %}" method="POST" name="add-edition-form">
{% csrf_token %} {% csrf_token %}
{{ work_form }} {{ work_form.title }}
{{ work_form.subtitle }}
{{ work_form.authors }}
{{ work_form.description }}
{{ work_form.languages }}
{{ work_form.series }}
{{ work_form.cover }}
{{ work_form.first_published_date }}
{% for subject in work.subjects %}
<input type="hidden" name="subjects" value="{{ subject }}">
{% endfor %}
<input type="hidden" name="parent_work" value="{{ work.id }}"> <input type="hidden" name="parent_work" value="{{ work.id }}">
<div> <div>
<button class="button is-small" type="submit"> <button class="button is-small" type="submit">

View file

@ -219,6 +219,7 @@ def create_book_from_data(request):
book = { book = {
"parent_work": {"id": request.POST.get("parent_work")}, "parent_work": {"id": request.POST.get("parent_work")},
"authors": models.Author.objects.filter(id__in=author_ids).all(), "authors": models.Author.objects.filter(id__in=author_ids).all(),
"subjects": request.POST.getlist("subjects"),
} }
data = {"book": book, "form": forms.EditionForm(request.POST)} data = {"book": book, "form": forms.EditionForm(request.POST)}