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
25 changes: 25 additions & 0 deletions src/genlab_bestilling/migrations/0014_alter_order_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.2.3 on 2025-06-19 15:26

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("genlab_bestilling", "0013_location_comment_alter_location_river_id"),
]

operations = [
migrations.AlterField(
model_name="order",
name="status",
field=models.CharField(
choices=[
("draft", "Draft"),
("confirmed", "Delivered"),
("processing", "Processing"),
("completed", "Completed"),
],
default="draft",
),
),
]
11 changes: 8 additions & 3 deletions src/genlab_bestilling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,19 @@ class CannotConfirm(ValidationError):
pass

class OrderStatus(models.TextChoices):
# DRAFT: External researcher has created the order, and is currently working on it before having it delivered for processing. # noqa: E501
DRAFT = "draft", _("Draft")
CONFIRMED = "confirmed", _("Confirmed")
# DELIVERED: Order has been delivered from researcher to the NINA staff.
# NOTE: # The old value `confirmed` was preserved during a name change to avoid migration issues. The primary goal is to have a more descriptive name for staff users in the GUI. # noqa: E501
DELIVERED = "confirmed", _("Delivered")
# PROCESSING: NINA staff has begun processing the order.
PROCESSING = "processing", _("Processing")
# COMPLETED: Order has been completed, and results are available.
COMPLETED = "completed", _("Completed")

STATUS_ORDER = (
OrderStatus.DRAFT,
OrderStatus.CONFIRMED,
OrderStatus.DELIVERED,
OrderStatus.PROCESSING,
OrderStatus.COMPLETED,
)
Expand All @@ -257,7 +262,7 @@ class OrderStatus(models.TextChoices):
objects = managers.OrderManager()

def confirm_order(self):
self.status = Order.OrderStatus.CONFIRMED
self.status = Order.OrderStatus.DELIVERED
self.confirmed_at = timezone.now()
self.save()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h5 class="text-2xl my-5">Samples to analyze</h5>
{% action-button action=confirm_order_url class="bg-secondary text-white" submit_text="Confirm Order" csrf_token=csrf_token %}
{% action-button action=clone_order_url class="bg-secondary text-white" submit_text="Clone Order" csrf_token=csrf_token %}
<a class="btn bg-red-500 text-white" href="{% url 'genrequest-analysis-delete' genrequest_id=object.genrequest_id pk=object.id %}">Delete</a>
{% elif object.status == 'confirmed' %}
{% elif object.status == object.OrderStatus.DELIVERED %}
<a class="btn bg-primary" href="{% url 'genrequest-analysis-samples' genrequest_id=object.genrequest_id pk=object.id %}">Samples</a>
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/staff/templates/staff/analysisorder_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h5 class="text-2xl my-5">Samples to analyze</h5>
<div class="flex gap-5 my-5">
<a class="btn bg-yellow-200" href="{% url 'staff:order-analysis-list' %}"><i class="fas fa-arrow-left"></i> back</a>
<a class="btn bg-primary" href="{% url 'staff:order-analysis-samples' pk=object.id %}">Samples</a>
{% if object.status == 'confirmed' %}
{% if object.status == object.OrderStatus.DELIVERED %}
<div class="ml-auto"></div>
{% url 'staff:order-to-draft' pk=object.id as to_draft_url %}
{% action-button action=to_draft_url class="bg-secondary text-white" submit_text="Convert to draft" csrf_token=csrf_token %}
Expand Down
2 changes: 1 addition & 1 deletion src/staff/templates/staff/extractionorder_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h5 class="text-2xl my-5">Delivered Samples</h5>
<div class="flex gap-5 my-5">
<a class="btn bg-yellow-200" href="{% url 'staff:order-extraction-list' %}"><i class="fas fa-arrow-left"></i> back</a>
<a class="btn bg-primary" href="{% url 'staff:order-extraction-samples' pk=object.id %}">Samples</a>
{% if object.status == 'confirmed' %}
{% if object.status == object.OrderStatus.DELIVERED %}
<div class="ml-auto"></div>
{% url 'staff:order-manually-checked' pk=object.id as confirm_check_url %}
{% url 'staff:order-to-draft' pk=object.id as to_draft_url %}
Expand Down
6 changes: 3 additions & 3 deletions src/staff/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class ManaullyCheckedOrderActionView(SingleObjectMixin, ActionView):
model = ExtractionOrder

def get_queryset(self):
return ExtractionOrder.objects.filter(status=Order.OrderStatus.CONFIRMED)
return ExtractionOrder.objects.filter(status=Order.OrderStatus.DELIVERED)

def post(self, request, *args, **kwargs):
self.object = self.get_object()
Expand Down Expand Up @@ -264,7 +264,7 @@ class OrderToDraftActionView(SingleObjectMixin, ActionView):
model = Order

def get_queryset(self):
return super().get_queryset().filter(status=Order.OrderStatus.CONFIRMED)
return super().get_queryset().filter(status=Order.OrderStatus.DELIVERED)

def post(self, request, *args, **kwargs):
self.object = self.get_object()
Expand Down Expand Up @@ -350,7 +350,7 @@ def get_queryset(self):
super()
.get_queryset()
.select_related("order")
.filter(order__status=Order.OrderStatus.CONFIRMED)
.filter(order__status=Order.OrderStatus.DELIVERED)
)

def post(self, request, *args, **kwargs):
Expand Down