From 1a5789afe9fb9521f5ca7ca5119870b1312dad3f Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Mon, 5 Jun 2023 15:59:39 +0200 Subject: [PATCH] add proofs toggle accessibility action --- .../_hx_productionstream_actions_proofs_item.html | 11 +++++++++++ scipost_django/production/views.py | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/scipost_django/production/templates/production/_hx_productionstream_actions_proofs_item.html b/scipost_django/production/templates/production/_hx_productionstream_actions_proofs_item.html index 03b30ce8d..af0f23f13 100644 --- a/scipost_django/production/templates/production/_hx_productionstream_actions_proofs_item.html +++ b/scipost_django/production/templates/production/_hx_productionstream_actions_proofs_item.html @@ -64,6 +64,17 @@ class="btn btn-sm btn-warning">Send proofs to authors</button> </div> </div> + {% else %} + <div class="col-12 col-sm-6 col-md-12 col-lg-6 h-100 d-none-empty"> + <div class="row m-0 d-none-empty"> + <button hx-get="{% url 'production:toggle_accessibility' proofs.stream.id proofs.version %}" + hx-target="#productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ proofs.version }}-item" + hx-swap="outerHTML" + class="btn btn-sm btn-primary"> + {{ proofs.accessible_for_authors|yesno:'Hide,Make accessible' }} for authors + </button> + </div> + </div> {% endif %} </div> diff --git a/scipost_django/production/views.py b/scipost_django/production/views.py index 5cc4eb4ad..02d8d929f 100644 --- a/scipost_django/production/views.py +++ b/scipost_django/production/views.py @@ -1103,7 +1103,16 @@ def toggle_accessibility(request, stream_id, version): proofs.accessible_for_authors = not proofs.accessible_for_authors proofs.save() messages.success(request, "Proofs accessibility updated.") - return redirect(stream.get_absolute_url()) + return render( + request, + "production/_hx_productionstream_actions_proofs_item.html", + { + "stream": stream, + "proofs": proofs, + "total_proofs": stream.proofs.count(), + "active_id": proofs.version, + }, + ) @is_production_user() -- GitLab