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 41ebacf5b616a60058af9eec9fa54c261f259320..c4c392e01101a85f7b10d8629a6d46d417bab332 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 c5418d1657200d379e7beb574213206c4391fdd8..adbce711bdb4e9576ee10dffdd898eaa974a6778 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()