From 711f2880fad5ef854f9be1710f2dbf2c49d1e322 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 8 Aug 2017 12:39:23 -0400 Subject: [PATCH] add ebook activation on edition edit --- frontend/templates/ebook_list.html | 18 ++++++++++++++++++ frontend/templates/edit_edition.html | 4 ++++ frontend/views/bibedit.py | 13 ++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 frontend/templates/ebook_list.html diff --git a/frontend/templates/ebook_list.html b/frontend/templates/ebook_list.html new file mode 100644 index 00000000..984f5143 --- /dev/null +++ b/frontend/templates/ebook_list.html @@ -0,0 +1,18 @@ +{% if work.ebooks_all %} +

Manage eBooks

+ +
+
+ + +{% endif %} \ No newline at end of file diff --git a/frontend/templates/edit_edition.html b/frontend/templates/edit_edition.html index 0d4d0de5..b0cd848d 100644 --- a/frontend/templates/edit_edition.html +++ b/frontend/templates/edit_edition.html @@ -217,7 +217,11 @@ ul.fancytree-container {

+ {% with edition.work as work %} + {% include 'ebook_list.html' %} + {% endwith %} + {% if edition.work %}

More Edition Management

diff --git a/frontend/views/bibedit.py b/frontend/views/bibedit.py index 47c17444..52143359 100644 --- a/frontend/views/bibedit.py +++ b/frontend/views/bibedit.py @@ -226,7 +226,18 @@ def edit_edition(request, work_id, edition_id, by=None): work_rel.delete() form = EditionForm(instance=edition, data=request.POST, files=request.FILES) break - + activate_all = request.POST.has_key('activate_all_ebooks') + deactivate_all = request.POST.has_key('deactivate_all_ebooks') + ebookchange = False + for ebook in work.ebooks_all(): + if request.POST.has_key('activate_ebook_%s' % ebook.id) or activate_all: + ebook.activate() + ebookchange = True + elif request.POST.has_key('deactivate_ebook_%s' % ebook.id) or deactivate_all: + ebook.deactivate() + ebookchange = True + if ebookchange: + form = EditionForm(instance=edition, data=request.POST, files=request.FILES) if request.POST.has_key('add_author_submit') and admin: new_author_name = request.POST['add_author'].strip() new_author_relation = request.POST['add_author_relation']