Skip to content

Commit c4eaa35

Browse files
authored
Add progress abr for isolated samples (#510)
1 parent ea9e461 commit c4eaa35

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/genlab_bestilling/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ def update_status(self) -> None:
363363
def filled_genlab_count(self) -> int:
364364
return self.samples.filter(genlab_id__isnull=False).count()
365365

366+
@property
367+
def isolated_count(self) -> int:
368+
return self.samples.filter(is_isolated=True).count()
369+
366370
@property
367371
def next_status(self) -> OrderStatus | None:
368372
current_index = self.STATUS_ORDER.index(self.status)

src/staff/templates/staff/sample_lab.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ <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+
<div class="flex items-center">
2122
{% for status in statuses %}
2223
<button class="btn btn-sm custom_order_button_green" type="submit" name="status" value="{{ status }}">
2324
{{ status|capfirst }}
2425
</button>
2526
{% endfor %}
26-
<div class="inline-block text-left mb-5">
27+
<div class="text-left">
2728
<button type="button"
2829
id="parent-dropdown-button"
2930
onclick="document.getElementById('parent-dropdown-menu').classList.toggle('hidden')"
@@ -53,6 +54,16 @@ <h3 class="text-4xl mb-5">{% block page-title %}{% if order %}Samples {{ order }
5354
{% endif %}
5455
</div>
5556
</div>
57+
<div class="ml-auto text-right w-full max-w-xs">
58+
<div class="mb-1 font-medium text-sm">
59+
{{ order.isolated_count }} / {{ order.samples.count }} isolated samples
60+
</div>
61+
<div class="w-full bg-gray-200 h-2 rounded">
62+
<div class="bg-[#C9EBB0] h-2 rounded" style="width:{{ progress_percent|default:0|floatformat:0 }}%;"></div>
63+
</div>
64+
</div>
65+
</div>
66+
<div class="mt-2"></div>
5667
{% render_table table %}
5768
</form>
5869
{% endblock page-inner %}

src/staff/views.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,13 @@ def get_base_fields(self) -> list[str]:
580580
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
581581
context = super().get_context_data(**kwargs)
582582
order = self.get_order()
583+
total_samples = order.samples.count()
584+
filled_count = order.isolated_count
585+
context["progress_percent"] = (
586+
(float(filled_count) / float(total_samples)) * 100
587+
if total_samples > 0
588+
else 0
589+
)
583590

584591
context.update(
585592
{

0 commit comments

Comments
 (0)