Skip to content

Commit 5f547e2

Browse files
committed
Added links to genlab ids and action text
1 parent 916f8d3 commit 5f547e2

File tree

6 files changed

+44
-1
lines changed

6 files changed

+44
-1
lines changed

src/staff/tables.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import django_tables2 as tables
44
from django.db.models import QuerySet
55
from django.templatetags.static import static
6+
from django.urls import reverse
67
from django.utils.html import format_html
78
from django.utils.safestring import mark_safe
89

@@ -270,6 +271,12 @@ class SampleBaseTable(tables.Table):
270271
empty_values=(),
271272
)
272273

274+
genlab_id = tables.Column(
275+
orderable=False,
276+
empty_values=(None,),
277+
verbose_name="Genlab ID",
278+
)
279+
273280
name = tables.Column()
274281

275282
class Meta:
@@ -317,6 +324,13 @@ def order_name(
317324
queryset = queryset.order_by(f"{prefix}name_as_int", "name")
318325
return (queryset, True)
319326

327+
def render_genlab_id(self, value: Any, record: Any) -> Any:
328+
from_url = reverse(
329+
"staff:order-extraction-samples", kwargs={"pk": record.order.pk}
330+
)
331+
url = reverse("staff:samples-detail", kwargs={"pk": record.id})
332+
return format_html('<a href="{}?from={}">{}</a>', url, from_url, value)
333+
320334

321335
class SampleStatusTable(tables.Table):
322336
"""
@@ -339,6 +353,12 @@ class SampleStatusTable(tables.Table):
339353
verbose_name="Mark",
340354
)
341355

356+
genlab_id = tables.Column(
357+
orderable=False,
358+
empty_values=(None,),
359+
verbose_name="Genlab ID",
360+
)
361+
342362
internal_note = tables.TemplateColumn(
343363
template_name="staff/note_input_column.html",
344364
orderable=False,
@@ -402,6 +422,13 @@ def render_checked(self, record: Any) -> str:
402422
record.id,
403423
)
404424

425+
def render_genlab_id(self, value: Any, record: Any) -> Any:
426+
from_url = reverse(
427+
"staff:order-extraction-samples-lab", kwargs={"pk": record.order.pk}
428+
)
429+
url = reverse("staff:samples-detail", kwargs={"pk": record.id})
430+
return format_html('<a href="{}?from={}">{}</a>', url, from_url, value)
431+
405432

406433
class OrderExtractionSampleTable(SampleBaseTable):
407434
class Meta(SampleBaseTable.Meta):

src/staff/templates/staff/sample_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<div class="flex gap-5 my-5">
88

9-
<a class="btn btn-tertiary" href="{% url 'staff:samples-list' %}"><i class="fas fa-arrow-left"></i> Back</a>
9+
<a class="btn btn-tertiary" href="{{ url }}"><i class="fas fa-arrow-left"></i> Back</a>
1010

1111
{% if user.is_staff %}
1212
<a class="btn custom_order_button ml-auto" href="{{ object.get_admin_change_url }}">

src/staff/templates/staff/sample_filter.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
{% csrf_token %}
3131
<input type="hidden" name="sort" value="{{ request.GET.sort|default:'' }}">
3232
{% next_url_input %}
33+
<h1 class="ml-2 mb-1 font-medium">Actions</h1>
34+
<h3 class="ml-2 mb-2 font-light text-gray-600">Select samples to generate genlabID</h3>
3335
<div class="flex gap-5 mb-5">
3436
<button class="btn btn-success" type="submit" name="generate_genlab_ids">
3537
<i class="fa-solid fa-id-badge"></i> Generate genlab IDs

src/staff/templates/staff/sample_lab.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ <h3 class="text-4xl mb-5">{% block page-title %}{% if order %}Samples {{ order }
1818
<form method="post" action="{% url 'staff:order-extraction-samples-lab' order.pk %}">
1919
{% csrf_token %}
2020
{% next_url_input %}
21+
<h1 class="ml-2 mb-1 font-medium">Actions</h1>
22+
<h3 class="ml-2 mb-2 font-light text-gray-600">Select samples to toggle status or set isolation method</h3>
2123
<div class="flex items-center">
2224
{% for status in statuses %}
2325
<button class="btn btn-sm btn-success" type="submit" name="status" value="{{ status }}">

src/staff/templates/staff/samplemarkeranalysis_filter.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ <h3 class="text-4xl mb-5">{% block page-title %}{% if order %}Samples {{ order }
1717
<form method="post" action="{% url 'staff:order-analysis-samples' order.pk %}">
1818
{% csrf_token %}
1919
{% next_url_input %}
20+
<h1 class="ml-2 mb-1 font-medium">Actions</h1>
21+
<h3 class="ml-2 mb-2 font-light text-gray-600">Select samples to toggle status</h3>
2022
{% for status in statuses %}
2123
<button class="btn btn-sm btn-success" type="submit" name="status" value="{{ status }}">
2224
{% if status == "pcr" %}

src/staff/views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,16 @@ def get_queryset(self) -> QuerySet[Sample]:
535535
class SampleDetailView(StaffMixin, DetailView):
536536
model = Sample
537537

538+
def get_context_data(self, **kwargs) -> dict[str, Any]:
539+
context = super().get_context_data(**kwargs)
540+
referer = self.request.GET.get("from")
541+
if referer:
542+
context["url"] = referer
543+
else:
544+
# Fallback to a default page
545+
context["url"] = reverse("staff:samples-list")
546+
return context
547+
538548

539549
class SampleLabView(StaffMixin, SingleTableMixin, SafeRedirectMixin, FilterView):
540550
MARKED = "marked"

0 commit comments

Comments
 (0)