diff --git a/scipost_django/mails/templates/mails/_hx_mail_form.html b/scipost_django/mails/templates/mails/_hx_mail_form.html new file mode 100644 index 0000000000000000000000000000000000000000..f2f1bfa257168005958dfdcb623c4f120011bb18 --- /dev/null +++ b/scipost_django/mails/templates/mails/_hx_mail_form.html @@ -0,0 +1,21 @@ +{% load bootstrap %} + +<h2 class="text-danger">HTMX send mail view is not working ATM.</h2> +<form enctype="multipart/form-data" + method="post" + class="border border-danger p-2"> + {% csrf_token %} + {% if transfer_data_form %}{{ transfer_data_form }}{% endif %} + {{ form|bootstrap }} + <div class="form-group row"> + <div class="offset-md-2 col-md-10"> + <input class="btn btn-outline-secondary me-2" + type="reset" + value="Reset to default"> + <button class="btn btn-primary me-2" + type="submit" + name="save" + value="send_from_editor">Send mail</button> + </div> + </div> +</form> 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 new file mode 100644 index 0000000000000000000000000000000000000000..03b30ce8d96356399a6ebf4d5ddbb545c80aafe4 --- /dev/null +++ b/scipost_django/production/templates/production/_hx_productionstream_actions_proofs_item.html @@ -0,0 +1,72 @@ +<div id="productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ proofs.version }}-item" + class="accordion-item"> + <h4 class="accordion-header"> + <button class="accordion-button {% if proofs.version != active_id %}collapsed{% endif %}" + type="button" + data-bs-toggle="collapse" + data-bs-target="#productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ proofs.version }}-body-container" + aria-expanded="false" + aria-controls="productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ proofs.version }}-body-container"> + <div class="row w-100 m-0 pe-2 align-items-center"> + <div class="col-6 col-sm col-lg-6 col-xl fs-6">Version {{ proofs.version }}</div> + <div class="col-6 col-sm-auto col-md-12 col-lg-6 col-xl-auto">{{ proofs.created|date:"DATE_FORMAT" }}</div> + <div class="col-12 col-sm-auto badge bg-secondary">{{ proofs.get_status_display|title }}</div> + </div> + </button> + </h4> + <div id="productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ proofs.version }}-body-container" + class="accordion-collapse collapse {% if proofs.version == active_id %}show{% endif %}" + data-bs-parent="#productionstream-{{ stream.id }}-proofs-list-accordion"> + <div class="accordion-body"> + <div class="row"> + <div class="col">Uploaded by:</div> + <div class="col-auto">{{ proofs.uploaded_by.user.first_name }} {{ proofs.uploaded_by.user.last_name }}</div> + </div> + <div class="row"> + <div class="col">Accessible for authors:</div> + <div class="col-auto"> + {{ proofs.accessible_for_authors|yesno:'<strong>Yes</strong>,No'|safe }} + </div> + </div> + + {% comment %} Buttons {% endcomment %} + <div id="productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ proofs.version }}-action-row" + class="row g-2"> + <div class="col-12 col-sm-6 col-md-12 col-lg-6 h-100 d-none-empty"> + <a class="row m-0 d-none-empty" + href="{% url 'production:proofs_pdf' proofs.slug %}"> + <button class="btn btn-sm btn-secondary">Download Proofs</button> + </a> + </div> + {% if proofs.status == 'uploaded' %} + <div class="col-6 col-sm-3 col-md-6 col-lg-3 h-100 d-none-empty"> + <div class="row m-0 d-none-empty"> + <button hx-get="{% url 'production:decision' proofs.stream.id proofs.version 'accept' %}" + hx-target="#productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ proofs.version }}-item" + hx-swap="outerHTML" + class="btn btn-sm btn-primary proof-action-button">Accept</button> + </div> + </div> + <div class="col-6 col-sm-3 col-md-6 col-lg-3 h-100 d-none-empty"> + <div class="row m-0 d-none-empty"> + <button hx-get="{% url 'production:decision' proofs.stream.id proofs.version 'decline' %}" + hx-target="#productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ proofs.version }}-item" + hx-swap="outerHTML" + class="btn btn-sm btn-danger proof-action-button">Decline</button> + </div> + </div> + {% elif proofs.status == 'accepted_sup' %} + <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:send_proofs' proofs.stream.id proofs.version %}" + hx-target="#productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ proofs.version }}-action-row" + hx-swap="afterend" + class="btn btn-sm btn-warning">Send proofs to authors</button> + </div> + </div> + {% endif %} + + </div> + </div> + </div> +</div> diff --git a/scipost_django/production/templates/production/_hx_productionstream_details_contents.html b/scipost_django/production/templates/production/_hx_productionstream_details_contents.html index 36d96074600a0c53c1fb07530e282cd3da59b450..35478433df82cadd62e2abefa1128b6b205e5994 100644 --- a/scipost_django/production/templates/production/_hx_productionstream_details_contents.html +++ b/scipost_django/production/templates/production/_hx_productionstream_details_contents.html @@ -169,7 +169,7 @@ class="overflow-scroll mb-4" style="max-height: max(50vh, 40em)" hx-get="{% url 'production:render_stream_events' productionstream.id %}" - hx-trigger="load, submit from:#productionstream-{{ productionstream.id }}-details target:form delay:500"> + hx-trigger="load, submit from:#productionstream-{{ productionstream.id }}-details target:form delay:500, click from:#productionstream-{{ productionstream.id }}-details target:.proof-action-button delay:500"> </div> <div id="productionstream-{{ productionstream.id }}-event-new-comment-form"> <button hx-get="{% url 'production:_hx_event_form' productionstream_id=productionstream.id %}" diff --git a/scipost_django/production/templates/production/_productionstream_details_summary_contents.html b/scipost_django/production/templates/production/_productionstream_details_summary_contents.html index dd1a194559f7856bc6a03c04e9aeffead7fbe16b..fba9f372ad5726b9775fd38bd7c8cf799a74596e 100644 --- a/scipost_django/production/templates/production/_productionstream_details_summary_contents.html +++ b/scipost_django/production/templates/production/_productionstream_details_summary_contents.html @@ -37,6 +37,6 @@ <div id="productionstream-{{ productionstream.id }}-summary-assignees" class="col-md-6" hx-get="{% url 'production:render_stream_assignees_status' productionstream.id %}" - hx-trigger="load, submit from:#productionstream-{{ productionstream.id }}-details target:form delay:500"> + hx-trigger="load, submit from:#productionstream-{{ productionstream.id }}-details target:form delay:500, click from:#productionstream-{{ productionstream.id }}-details target:.proof-action-button delay:500"> </div> </div> diff --git a/scipost_django/production/templates/production/upload_proofs.html b/scipost_django/production/templates/production/upload_proofs.html index 01ca25458692607633deba709a67c58c82576c7e..a1ba1307b12910c724c8d56ccc05eb5ef4c2c3ed 100644 --- a/scipost_django/production/templates/production/upload_proofs.html +++ b/scipost_django/production/templates/production/upload_proofs.html @@ -5,100 +5,7 @@ <div class="accordion" id="productionstream-{{ stream.id }}-proofs-list-accordion"> {% for proofs in stream.proofs.all %} - <div class="accordion-item"> - <h4 class="accordion-header"> - <button class="accordion-button {% if forloop.counter0|add:1 != total_proofs %}collapsed{% endif %}" - type="button" - data-bs-toggle="collapse" - data-bs-target="#productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ forloop.counter0 }}" - aria-expanded="false" - aria-controls="productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ forloop.counter0 }}"> - <div class="row w-100 m-0 pe-2 align-items-center"> - <div class="col-6 col-sm col-lg-6 col-xl fs-6">Version {{ proofs.version }}</div> - <div class="col-6 col-sm-auto col-md-12 col-lg-6 col-xl-auto">{{ proofs.created|date:"DATE_FORMAT" }}</div> - <div class="col-12 col-sm-auto badge bg-secondary">{{ proofs.get_status_display|title }}</div> - </div> - </button> - </h4> - <div id="productionstream-{{ stream.id }}-proofs-list-accordion-proofs-{{ forloop.counter0 }}" - class="accordion-collapse collapse {% if forloop.counter0|add:1 == total_proofs %}show{% endif %}" - data-bs-parent="#productionstream-{{ stream.id }}-proofs-list-accordion"> - <div class="accordion-body"> - <div class="row"> - <div class="col">Uploaded by:</div> - <div class="col-auto">{{ proofs.uploaded_by.user.first_name }} {{ proofs.uploaded_by.user.last_name }}</div> - </div> - <div class="row"> - <div class="col">Accessible for authors:</div> - <div class="col-auto"> - {{ proofs.accessible_for_authors|yesno:'<strong>Yes</strong>,No'|safe }} - </div> - </div> - - {% comment %} Buttons {% endcomment %} - <div class="row g-2"> - <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 class="btn btn-sm btn-secondary" - hx-get="{% url 'production:proofs' stream_id=stream.id version=proofs.version %}"> - Download Proofs - </button> - </div> - </div> - {% if proofs.status == 'uploaded' %} - <div class="col-6 col-sm-3 col-md-6 col-lg-3 h-100 d-none-empty"> - <div class="row m-0 d-none-empty"> - <button class="btn btn-sm btn-primary">Accept</button> - </div> - </div> - <div class="col-6 col-sm-3 col-md-6 col-lg-3 h-100 d-none-empty"> - <div class="row m-0 d-none-empty"> - <button class="btn btn-sm btn-danger">Decline</button> - </div> - </div> - </div> - {% elif proofs.status == 'accepted_sup' %} - <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 class="btn btn-sm btn-warning" - hx-get="{% url 'production:proofs' stream_id=stream.id version=proofs.version %}"> - Send proofs to authors - </button> - </div> - </div> - {% endif %} - - </div> - </div> - </div> - - - {% comment %} <li class="py-1"> - <a href="{% url 'production:proofs' stream_id=stream.id version=proofs.version %}">Version {{ proofs.version }}</a> · <span class="label label-secondary label-sm">{{ proofs.get_status_display }}</span> - <br> - Uploaded by: {{ proofs.uploaded_by.user.first_name }} {{ proofs.uploaded_by.user.last_name }} - <br> - Accessible for authors: {{ proofs.accessible_for_authors|yesno:'<strong>Yes</strong>,No'|safe }} - <br> - - {% if perms.scipost.can_run_proofs_by_authors %} - {% if proofs.status == 'uploaded' %} - <strong><span class="text-danger">See details for open actions:</span></strong> - <ul> - <li> - <a href="{% url 'production:proofs' stream_id=stream.id version=proofs.version %}">Accept or decline proofs</a> - </li> - </ul> - {% elif proofs.status == 'accepted_sup' %} - <strong><span class="text-danger">See details for open actions:</span></strong> - <ul> - <li> - <a href="{% url 'production:proofs' stream_id=stream.id version=proofs.version %}">Send proofs to authors</a> - </li> - </ul> - {% endif %} - {% endif %} - </li> {% endcomment %} + {% include 'production/_hx_productionstream_actions_proofs_item.html' with i_proof=forloop.counter0|add:1 active_id=total_proofs stream=stream proofs=proofs %} {% empty %} <div>No Proofs found.</div> {% endfor %} @@ -109,7 +16,10 @@ <form method="post" enctype="multipart/form-data"> {% csrf_token %} {{ form|bootstrap_purely_inline }} - <input type="submit" class="btn btn-primary" name="submit" value="Upload"> + <input type="submit" + class="btn btn-primary proof-action-button" + name="submit" + value="Upload"> </form> </div> </div> diff --git a/scipost_django/production/views.py b/scipost_django/production/views.py index 289324ee71e0db6c8623018baf51cf537e05bca2..5cc4eb4ad662bf11c2678c5d7053407bbc4c3923 100644 --- a/scipost_django/production/views.py +++ b/scipost_django/production/views.py @@ -20,7 +20,7 @@ from guardian.core import ObjectPermissionChecker from guardian.shortcuts import assign_perm, remove_perm from finances.forms import WorkLogForm -from mails.views import MailEditorSubview +from mails.views import MailEditorSubviewHTMX from . import constants from .models import ( @@ -1145,7 +1145,16 @@ def decision(request, stream_id, version, decision): ) prodevent.save() messages.success(request, "Proofs have been {decision}.".format(decision=decision)) - return redirect(reverse("production:proofs", args=(stream.id, proofs.version))) + 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() @@ -1176,7 +1185,9 @@ def send_proofs(request, stream_id, version): stream.status = constants.PROOFS_SENT stream.save() - mail_request = MailEditorSubview(request, "production_send_proofs", proofs=proofs) + mail_request = MailEditorSubviewHTMX( + request, "production_send_proofs", proofs=proofs + ) if mail_request.is_valid(): proofs.save() stream.save()