diff --git a/src/genlab_bestilling/templates/genlab_bestilling/analysisorder_detail.html b/src/genlab_bestilling/templates/genlab_bestilling/analysisorder_detail.html
index 11812109..982a072d 100644
--- a/src/genlab_bestilling/templates/genlab_bestilling/analysisorder_detail.html
+++ b/src/genlab_bestilling/templates/genlab_bestilling/analysisorder_detail.html
@@ -44,7 +44,9 @@
Samples to analyze
{% url 'genrequest-order-clone' genrequest_id=object.genrequest_id pk=object.id as clone_order_url %}
{% action-button action=confirm_order_url class="btn custom_order_button" submit_text="Deliver order" csrf_token=csrf_token %}
{% action-button action=clone_order_url class="btn custom_order_button" submit_text="Clone Order" csrf_token=csrf_token %}
+ {% if all_samples_have_no_genlab_id %}
Delete
+ {% endif %}
{% elif object.status == object.OrderStatus.DELIVERED %}
Samples
{% endif %}
diff --git a/src/genlab_bestilling/templates/genlab_bestilling/extractionorder_detail.html b/src/genlab_bestilling/templates/genlab_bestilling/extractionorder_detail.html
index 0342d567..044bbcde 100644
--- a/src/genlab_bestilling/templates/genlab_bestilling/extractionorder_detail.html
+++ b/src/genlab_bestilling/templates/genlab_bestilling/extractionorder_detail.html
@@ -24,8 +24,9 @@ Order {{ object }}
{% url 'genrequest-order-confirm' genrequest_id=object.genrequest_id pk=object.id as confirm_order_url %}
{% action-button action=confirm_order_url class="btn custom_order_button" submit_text="Deliver order" csrf_token=csrf_token %}
-
+ {% if all_samples_have_no_genlab_id %}
Delete
+ {% endif %}
{% endif %}
Samples
diff --git a/src/genlab_bestilling/views.py b/src/genlab_bestilling/views.py
index ed8e464a..19b6874b 100644
--- a/src/genlab_bestilling/views.py
+++ b/src/genlab_bestilling/views.py
@@ -475,6 +475,15 @@ def get_queryset(self) -> QuerySet:
.prefetch_related("sample_markers", "markers")
)
+ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
+ context = super().get_context_data(**kwargs)
+ order = self.object
+ all_samples_have_no_genlab_id = not order.samples.exclude(
+ genlab_id__isnull=True
+ ).exists()
+ context["all_samples_have_no_genlab_id"] = all_samples_have_no_genlab_id
+ return context
+
class ExtractionOrderDetailView(GenrequestNestedMixin, DetailView):
model = ExtractionOrder
@@ -499,6 +508,15 @@ def gen_crumbs(self) -> list[tuple]:
(str(self.object), ""),
]
+ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
+ context = super().get_context_data(**kwargs)
+ order = self.object
+ all_samples_have_no_genlab_id = not order.samples.exclude(
+ genlab_id__isnull=True
+ ).exists()
+ context["all_samples_have_no_genlab_id"] = all_samples_have_no_genlab_id
+ return context
+
class GenrequestOrderDeleteView(GenrequestNestedMixin, DeleteView):
model = Order