Skip to content

Commit 78ca1c3

Browse files
mortenlynMorten Madsen Lyngstad
andauthored
Add button to link from extraction order to related analysis order (#198)
Co-authored-by: Morten Madsen Lyngstad <morten.lyngstad@bekk.no>
1 parent f9239d1 commit 78ca1c3

File tree

2 files changed

+35
-19
lines changed

2 files changed

+35
-19
lines changed

src/staff/templates/staff/extractionorder_detail.html

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,22 @@
33

44

55
{% block content %}
6-
{% fragment as table_header %}
7-
{% #table-cell header=True %}GUID{% /table-cell %}
8-
{% #table-cell header=True %}Type{% /table-cell %}
9-
{% #table-cell header=True %}Species{% /table-cell %}
10-
{% #table-cell header=True %}Markers{% /table-cell %}
11-
{% #table-cell header=True %}Location{% /table-cell %}
12-
{% #table-cell header=True %}Date{% /table-cell %}
13-
{% #table-cell header=True %}Volume{% /table-cell %}
14-
{% endfragment %}
156
<h3 class="text-4xl mb-5">Order {{ object }}</h3>
16-
<div class="flex gap-5 mb-5">
17-
</div>
18-
19-
{% object-detail object=object %}
20-
21-
22-
<h5 class="text-2xl my-5">Delivered Samples</h5>
23-
<div class="bg-white p-4">
24-
<p>{{ object.samples.count }} samples were delivered</p>
25-
</div>
7+
<div class="flex gap-5 mb-5"></div>
268

279
<div class="flex gap-5 my-5">
2810
<a class="btn bg-yellow-200" href="{% url 'staff:order-extraction-list' %}"><i class="fas fa-arrow-left"></i> back</a>
2911
<a class="btn bg-primary" href="{% url 'staff:order-extraction-samples' pk=object.id %}">Samples</a>
12+
{% if analysis_orders|length > 1 %}
13+
<select id="analysis-select" class="btn bg-yellow-200" onchange="if(this.value) { window.location.href = this.value; }" style="width: 13rem;">
14+
<option value="">Go to Analysis Order</option>
15+
{% for ao in analysis_orders %}
16+
<option value="{% url 'staff:order-analysis-detail' pk=ao.id %}">{{ ao }}</option>
17+
{% endfor %}
18+
</select>
19+
{% elif analysis_orders|length == 1 %}
20+
<a class="btn bg-yellow-200" href="{% url 'staff:order-analysis-detail' pk=analysis_orders.first.id %}">Go to {{ analysis_orders.first}}</a>
21+
{% endif %}
3022
<a class="btn bg-primary" href="{% url 'staff:order-add-staff' pk=object.id %}">Assign staff</a>
3123

3224
<div class="ml-auto"></div>
@@ -46,5 +38,23 @@ <h5 class="text-2xl my-5">Delivered Samples</h5>
4638
{% action-button action=to_next_status_url class="bg-secondary text-white" submit_text=btn_name csrf_token=csrf_token %}
4739
{% endwith %}
4840
{% endif %}
41+
42+
</div>
43+
44+
{% fragment as table_header %}
45+
{% #table-cell header=True %}GUID{% /table-cell %}
46+
{% #table-cell header=True %}Type{% /table-cell %}
47+
{% #table-cell header=True %}Species{% /table-cell %}
48+
{% #table-cell header=True %}Markers{% /table-cell %}
49+
{% #table-cell header=True %}Location{% /table-cell %}
50+
{% #table-cell header=True %}Date{% /table-cell %}
51+
{% #table-cell header=True %}Volume{% /table-cell %}
52+
{% endfragment %}
53+
54+
{% object-detail object=object %}
55+
56+
<h5 class="text-2xl my-5">Delivered Samples</h5>
57+
<div class="bg-white p-4">
58+
<p>{{ object.samples.count }} samples were delivered</p>
4959
</div>
5060
{% endblock %}

src/staff/views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ class EquipmentOrderDetailView(StaffMixin, DetailView):
172172
class ExtractionOrderDetailView(StaffMixin, DetailView):
173173
model = ExtractionOrder
174174

175+
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
176+
context = super().get_context_data(**kwargs)
177+
extraction_order = self.object
178+
context["analysis_orders"] = extraction_order.analysis_orders.all()
179+
return context
180+
175181

176182
class OrderExtractionSamplesListView(StaffMixin, SingleTableMixin, FilterView):
177183
table_pagination = False

0 commit comments

Comments
 (0)