From ad8bb54ce436bb928820a2dd4320d8b2956c3f03 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Thu, 1 Jun 2023 15:36:04 +0200 Subject: [PATCH] add complete production stream action add create draft publication production stream action --- ..._hx_productionstream_details_contents.html | 26 +++++++++++++++++-- scipost_django/production/views.py | 24 ++++++++++------- 2 files changed, 39 insertions(+), 11 deletions(-) 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 41ebacf5b..c4c392e01 100644 --- a/scipost_django/production/templates/production/_hx_productionstream_details_contents.html +++ b/scipost_django/production/templates/production/_hx_productionstream_details_contents.html @@ -24,8 +24,30 @@ {% endif %} <ul> <li>Worklog</li> - <li>Completed</li> - <li>Upload proofs</li> + + {% if perms.scipost.can_publish_accepted_submission %} + <div class="row"> + <div class="col-12 col-sm-auto col-md-12 col-lg-auto h-100 d-none-empty"> + <div class="row m-0 d-none-empty"> + <button class="btn btn-sm btn-warning text-white" hx-get="{% url 'production:mark_as_completed' stream_id=productionstream.id %}" hx-confim="Are you sure you want to mark this stream as completed?" hx-target="#productionstream-{{ productionstream.id }}-details"> + Mark this stream as completed + </button> + </div> + </div> + </div> + {% endif %} + + {% if perms.scipost.can_draft_publication and stream.status == 'accepted' %} + <div class="row"> + <div class="col-12 col-sm-auto col-md-12 col-lg-auto h-100 d-none-empty"> + <div class="row m-0 d-none-empty"> + <a class="btn btn-sm btn-primary text-white" href="{% url 'journals:create_publication' productionstream.submission.preprint.identifier_w_vn_nr %}"> + Draft publication + </a> + </div> + </div> + </div> + {% endif %} <li>Accessibility</li> <li>Send Proofs</li> </ul> diff --git a/scipost_django/production/views.py b/scipost_django/production/views.py index c5418d165..adbce711b 100644 --- a/scipost_django/production/views.py +++ b/scipost_django/production/views.py @@ -825,20 +825,26 @@ class DeleteEventView(DeleteView): @permission_required("scipost.can_publish_accepted_submission", raise_exception=True) @transaction.atomic def mark_as_completed(request, stream_id): - stream = get_object_or_404(ProductionStream.objects.ongoing(), pk=stream_id) - stream.status = constants.PRODUCTION_STREAM_COMPLETED - stream.closed = timezone.now() - stream.save() + productionstream = get_object_or_404( + ProductionStream.objects.ongoing(), pk=stream_id + ) + productionstream.status = constants.PRODUCTION_STREAM_COMPLETED + productionstream.closed = timezone.now() + productionstream.save() - prodevent = ProductionEvent( - stream=stream, + production_event = ProductionEvent( + stream=productionstream, event="status", comments=" marked the Production Stream as completed.", noted_by=request.user.production_user, ) - prodevent.save() - messages.success(request, "Stream marked as completed.") - return redirect(reverse("production:production")) + production_event.save() + + return HttpResponse( + r"""<summary class="text-white bg-success summary-unstyled p-3"> + Production Stream has been marked as completed. + </summary>""" + ) @is_production_user() -- GitLab