forked from mirrors/bookwyrm
Remove author flow
This commit is contained in:
parent
f1b699d810
commit
79d9c493f7
2 changed files with 12 additions and 6 deletions
|
@ -103,12 +103,14 @@
|
||||||
|
|
||||||
<section class="block">
|
<section class="block">
|
||||||
<h2 class="title is-4">{% trans "Authors" %}</h2>
|
<h2 class="title is-4">{% trans "Authors" %}</h2>
|
||||||
|
<fieldset>
|
||||||
{% for author in book.authors.all %}
|
{% for author in book.authors.all %}
|
||||||
<p><a href="{{ author.local_path }}">{{ author.name }}</a>
|
<p><a href="{{ author.local_path }}">{{ author.name }}</a>
|
||||||
<label class="label">
|
<label class="label">
|
||||||
<input type="checkbox" name="remove_author" value="{{ author.id }}"> {% trans "Remove this author" %}
|
<input type="checkbox" name="remove_authors" value="{{ author.id }}"> {% trans "Remove this author" %}
|
||||||
</label>
|
</label>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</fieldset>
|
||||||
{% if confirm_mode %}
|
{% if confirm_mode %}
|
||||||
<input type="hidden" name="add_author" value="{{ add_author }}">
|
<input type="hidden" name="add_author" value="{{ add_author }}">
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -163,6 +163,10 @@ class EditBook(View):
|
||||||
data['confirm_mode'] = True
|
data['confirm_mode'] = True
|
||||||
return TemplateResponse(request, 'edit_book.html', data)
|
return TemplateResponse(request, 'edit_book.html', data)
|
||||||
|
|
||||||
|
remove_authors = request.POST.getlist('remove_authors')
|
||||||
|
for author_id in remove_authors:
|
||||||
|
book.authors.remove(author_id)
|
||||||
|
|
||||||
book = form.save()
|
book = form.save()
|
||||||
return redirect('/book/%s' % book.id)
|
return redirect('/book/%s' % book.id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue