Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/genlab_bestilling/migrations/0020_sample_is_prioritised.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.2.3 on 2025-07-07 06:40

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
(
"genlab_bestilling",
"0019_isolationmethod_samplestatus_samplestatusassignment_and_more",
),
]

operations = [
migrations.AddField(
model_name="sample",
name="is_prioritised",
field=models.BooleanField(
default=False,
help_text="Check this box if the sample is prioritised for processing",
),
),
]
4 changes: 4 additions & 0 deletions src/genlab_bestilling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ class Sample(models.Model):
)

objects = managers.SampleQuerySet.as_manager()
is_prioritised = models.BooleanField(
default=False,
help_text="Check this box if the sample is prioritised for processing",
)

def __str__(self) -> str:
return self.genlab_id or f"#SMP_{self.id}"
Expand Down
8 changes: 8 additions & 0 deletions src/staff/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ class SampleBaseTable(tables.Table):
empty_values=(), orderable=False, verbose_name="Extraction position"
)

is_prioritised = tables.TemplateColumn(
template_name="staff/prioritise_flag.html",
orderable=True,
verbose_name="",
)

class Meta:
model = Sample
fields = [
Expand All @@ -148,6 +154,8 @@ class Meta:
"plate_positions",
]
attrs = {"class": "w-full table-auto tailwind-table table-sm"}
sequence = ("is_prioritised", "genlab_id", "guid", "name", "species", "type")
order_by = ("-is_prioritised", "species", "genlab_id", "name")

empty_text = "No Samples"

Expand Down
8 changes: 8 additions & 0 deletions src/staff/templates/staff/prioritise_flag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<form method="post" action="{% url 'staff:order-extraction-samples' pk=record.order_id %}" style="display:inline;">
{% csrf_token %}
<input type="hidden" name="sample_id" value="{{ record.pk }}">
<button type="submit" title="Toggle prioritised">
{% csrf_token %}
<i class="fa-solid fa-flag {% if record.is_prioritised %}text-blue-500{% else %}text-gray-300{% endif %}"></i>
</button>
</form>
12 changes: 12 additions & 0 deletions src/staff/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ def get_context_data(self, **kwargs) -> dict[str, Any]:
context["order"] = ExtractionOrder.objects.get(pk=self.kwargs.get("pk"))
return context

def post(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
sample_id = request.POST.get("sample_id")

if sample_id:
sample = get_object_or_404(Sample, pk=sample_id)
sample.is_prioritised = not sample.is_prioritised
sample.save()

return self.get(
request, *args, **kwargs
) # Re-render the view with updated data


class OrderAnalysisSamplesListView(StaffMixin, SingleTableMixin, FilterView):
table_pagination = False
Expand Down