{% block page-title %}{% if order %}{{ order }} - Samp
const noteInputs = document.querySelectorAll('.internal_note-input');
selectAll?.addEventListener('change', function() {
- const checkboxes = document.querySelectorAll('input[type="checkbox"]');
+ const checkboxes = document.querySelectorAll(`input[name="checked-{{ order.pk }}"]`);
checkboxes.forEach((cb) => {
cb.checked = selectAll.checked;
})
diff --git a/src/staff/views.py b/src/staff/views.py
index 1a60ab35..5f44b6d3 100644
--- a/src/staff/views.py
+++ b/src/staff/views.py
@@ -4,7 +4,7 @@
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from django.db import models
-from django.db.models import Count
+from django.db.models import Count, Exists, OuterRef
from django.forms import Form
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect, JsonResponse
from django.shortcuts import get_object_or_404
@@ -376,7 +376,7 @@ def get_success_url(self) -> str:
def post(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
status_name = request.POST.get("status")
- selected_ids = request.POST.getlist("checked")
+ selected_ids = request.POST.getlist(f"checked-{self.get_order().pk}")
isolation_method = request.POST.get("isolation_method")
if not selected_ids:
@@ -390,6 +390,10 @@ def post(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
if status_name:
self.assign_status_to_samples(samples, status_name, order, request)
+ if status_name == "isolated":
+ # Cannot use "samples" here
+ # because we need to check all samples in the order
+ self.check_all_isolated(Sample.objects.filter(order=order))
if isolation_method:
self.update_isolation_methods(samples, isolation_method, request)
return HttpResponseRedirect(self.get_success_url())
@@ -436,6 +440,25 @@ def assign_status_to_samples(
request, f"{samples.count()} samples updated with status '{status_name}'."
)
+ # Checks if all samples in the order are isolated
+ # If they are, it updates the order status to completed
+ def check_all_isolated(self, samples: models.QuerySet) -> None:
+ samples_with_flag = samples.annotate(
+ has_isolated=Exists(
+ SampleStatusAssignment.objects.filter(
+ sample=OuterRef("pk"),
+ status=SampleStatusAssignment.SampleStatus.ISOLATED,
+ )
+ )
+ )
+
+ if not samples_with_flag.filter(has_isolated=False).exists():
+ self.get_order().to_next_status()
+ messages.success(
+ self.request,
+ "All samples are isolated. The order status is updated to completed.",
+ )
+
def update_isolation_methods(
self, samples: models.QuerySet, isolation_method: str, request: HttpRequest
) -> None:
From 6dd52a7b0c4816e968f67830289f6d0360b4e3bd Mon Sep 17 00:00:00 2001
From: Ole Magnus
Date: Mon, 14 Jul 2025 08:11:01 +0200
Subject: [PATCH 03/23] Add priority to urgent orders table (#251)
---
src/staff/tables.py | 9 ++++++++-
src/staff/templatetags/order_tags.py | 7 +++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/staff/tables.py b/src/staff/tables.py
index 009ce00f..772be91a 100644
--- a/src/staff/tables.py
+++ b/src/staff/tables.py
@@ -390,6 +390,13 @@ def render_id(
class UrgentOrderTable(StaffIDMixinTable, StatusMixinTable):
+ priority = tables.TemplateColumn(
+ orderable=False,
+ verbose_name="Priority",
+ accessor="priority",
+ template_name="staff/components/priority_column.html",
+ )
+
description = tables.Column(
accessor="genrequest__name",
verbose_name="Description",
@@ -409,7 +416,7 @@ def render_delivery_date(self, value: Any) -> str:
class Meta:
model = Order
- fields = ["id", "description", "delivery_date", "status"]
+ fields = ["priority", "id", "description", "delivery_date", "status"]
empty_text = "No urgent orders"
template_name = "django_tables2/tailwind_inner.html"
diff --git a/src/staff/templatetags/order_tags.py b/src/staff/templatetags/order_tags.py
index 77f63f48..b9c6046f 100644
--- a/src/staff/templatetags/order_tags.py
+++ b/src/staff/templatetags/order_tags.py
@@ -22,6 +22,13 @@ def urgent_orders_table(context: dict, area: Area | None = None) -> dict:
)
.exclude(status=Order.OrderStatus.DRAFT)
.select_related("genrequest")
+ .annotate(
+ priority=models.Case(
+ models.When(is_urgent=True, then=Order.OrderPriority.URGENT),
+ models.When(is_prioritized=True, then=Order.OrderPriority.PRIORITIZED),
+ default=1,
+ ),
+ )
)
if area:
From a223d847a0b82652a21168eb49ab4208257e1f0a Mon Sep 17 00:00:00 2001
From: Morten Lyngstad <81157760+mortenlyn@users.noreply.github.com>
Date: Mon, 14 Jul 2025 09:08:48 +0200
Subject: [PATCH 04/23] Exclude 'pop_id' and 'location' fields from
OrderExtractionSampleTable (#254)
Co-authored-by: Morten Madsen Lyngstad
---
src/staff/tables.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/staff/tables.py b/src/staff/tables.py
index 772be91a..55933332 100644
--- a/src/staff/tables.py
+++ b/src/staff/tables.py
@@ -292,7 +292,7 @@ def render_checked(self, record: Any) -> str:
class OrderExtractionSampleTable(SampleBaseTable):
class Meta(SampleBaseTable.Meta):
- fields = SampleBaseTable.Meta.fields
+ exclude = ("pop_id", "location")
class OrderAnalysisSampleTable(tables.Table):
From 9cf89ff5f2d643169382c46870c952dcc89cb5cc Mon Sep 17 00:00:00 2001
From: Bertine <112892518+aastabk@users.noreply.github.com>
Date: Mon, 14 Jul 2025 10:21:14 +0200
Subject: [PATCH 05/23] Only genrequest members can mark an order as seen
(#252)
* Only genrequest members can mark an order as seen
* Move logic closer to frontend
* Removed unnecessary code, checks buttons everywhere, added check in post.
* Removed prints
* Fixed linter error
---
src/staff/tables.py | 4 ++--
src/staff/templates/staff/analysisorder_detail.html | 3 ++-
src/staff/templates/staff/components/seen_column.html | 8 +++++++-
src/staff/templates/staff/extractionorder_detail.html | 3 ++-
src/staff/templatetags/order_tags.py | 6 ++++++
src/staff/views.py | 11 +++++++++++
6 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/staff/tables.py b/src/staff/tables.py
index 55933332..b64a29d1 100644
--- a/src/staff/tables.py
+++ b/src/staff/tables.py
@@ -423,10 +423,10 @@ class Meta:
class NewUnseenOrderTable(StaffIDMixinTable):
seen = tables.TemplateColumn(
+ verbose_name="",
orderable=False,
- verbose_name="Seen",
- template_name="staff/components/seen_column.html",
empty_values=(),
+ template_name="staff/components/seen_column.html",
)
description = tables.Column(
diff --git a/src/staff/templates/staff/analysisorder_detail.html b/src/staff/templates/staff/analysisorder_detail.html
index fc2ae045..a31480dd 100644
--- a/src/staff/templates/staff/analysisorder_detail.html
+++ b/src/staff/templates/staff/analysisorder_detail.html
@@ -1,5 +1,6 @@
{% extends "staff/base.html" %}
{% load i18n %}
+{% load order_tags %}
{% block content %}
@@ -18,7 +19,7 @@
Order {{ object }}
- {% if not object.is_seen %}
+ {% if object.genrequest.responsible_staff.all|is_responsible:request.user and not object.is_seen %}
+{% endif %}
diff --git a/src/staff/templates/staff/extractionorder_detail.html b/src/staff/templates/staff/extractionorder_detail.html
index 40da9dbd..f48e3e2b 100644
--- a/src/staff/templates/staff/extractionorder_detail.html
+++ b/src/staff/templates/staff/extractionorder_detail.html
@@ -1,5 +1,6 @@
{% extends "staff/base.html" %}
{% load i18n %}
+{% load order_tags %}
{% block content %}
@@ -38,7 +39,7 @@
Order {{ object }}
- {% if not object.is_seen %}
+ {% if object.genrequest.responsible_staff.all|is_responsible:request.user and not object.is_seen %}
diff --git a/src/staff/templates/staff/project_detail.html b/src/staff/templates/staff/project_detail.html
index 1a6b19e3..4aa8eb2a 100644
--- a/src/staff/templates/staff/project_detail.html
+++ b/src/staff/templates/staff/project_detail.html
@@ -7,7 +7,7 @@
Project {{ object }}
- back
+ Back
{% url 'staff:projects-verify' pk=object.pk as verify_url %}
{% if object.verified_at is null %}
{% action-button action=verify_url class="btn-secondary text-white" submit_text="Mark as verified" csrf_token=csrf_token %}
diff --git a/src/staff/templates/staff/project_filter.html b/src/staff/templates/staff/project_filter.html
index b0434b4c..dc7c836d 100644
--- a/src/staff/templates/staff/project_filter.html
+++ b/src/staff/templates/staff/project_filter.html
@@ -10,8 +10,8 @@