Skip to content
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
10672e3
Add 'is_urgent' field to Order model and update related forms
Jun 19, 2025
22deb0c
Implement DashboardView and create dashboard template for urgent GenR…
Jun 20, 2025
83e255a
Fix broken alias. (#82)
emilte Jun 20, 2025
a2ae12e
Add week number and date to dashboard frontpage
omfj Jun 20, 2025
350e665
Display confirmed orders on dashboard frontpage
omfj Jun 20, 2025
085e130
Rearrange dashboard header elements for improved layout
Jun 20, 2025
0f794e0
Change status Confirmed to Delivered. (#80)
emilte Jun 21, 2025
1377a8a
Remove capitalize function
omfj Jun 23, 2025
777f4fe
Reformat code
omfj Jun 23, 2025
afb3b9f
Merge migrations
omfj Jun 23, 2025
f4ae676
Add help text for is_urgent field in EquipmentOrder model and remove …
Jun 23, 2025
e99c9b8
Use 'source' instead of '.' for loading aliases-private.sh in aliases.sh
Jun 23, 2025
bafa9d1
Remove redundant label for is_urgent field in forms
Jun 23, 2025
4f99de2
Change confirmed_orders filter status from CONFIRMED to DELIVERED in …
Jun 23, 2025
a0168dc
Merge pull request #89 from NINAnor/remove_label_overrides
omfj Jun 24, 2025
415e876
Added a field for person to contact with an email field on a per orde…
aastabk Jun 25, 2025
fce7bc2
Merge branch 'summer25' into add-responsible-scientist
aastabk Jun 25, 2025
57f6255
Draft to display the urgent orders. See tailwind.html for the current…
aastabk Jun 23, 2025
086a2f9
fix
omfj Jun 23, 2025
4c7e1a4
The tables are now sorted by the "is_urgent" field with the "true" va…
aastabk Jun 23, 2025
7b3e460
Added comment to the tailwind.html file.
aastabk Jun 25, 2025
0aa43f6
Use django template to render date and week
omfj Jun 23, 2025
e4b9716
Refactor urgent orders handling in DashboardView and template
Jun 25, 2025
206c59e
Merge pull request #90 from NINAnor/omfj/django-template-render-date
mortenlyn Jun 25, 2025
a32de13
Merge branch 'summer25' into 94-list-urgent-orders-on-dashboard
mortenlyn Jun 25, 2025
b30dc60
Merge pull request #98 from NINAnor/94-list-urgent-orders-on-dashboard
aastabk Jun 25, 2025
c4980fb
Deleted redundant label fields.
aastabk Jun 25, 2025
5123c5a
Draft to display the urgent orders. See tailwind.html for the current…
aastabk Jun 23, 2025
e3dc8cb
fix
omfj Jun 23, 2025
d6af646
The tables are now sorted by the "is_urgent" field with the "true" va…
aastabk Jun 23, 2025
f1cd46a
Added comment to the tailwind.html file.
aastabk Jun 25, 2025
a8dd26b
Refactor urgent orders handling in DashboardView and template
Jun 25, 2025
ad16c86
Use django template to render date and week
omfj Jun 23, 2025
4757a30
Added a field for person to contact with an email field on a per orde…
aastabk Jun 25, 2025
c2f7315
Merge branch 'summer25' into add-responsible-scientist
aastabk Jun 25, 2025
cf37435
Remove unnecessary whitespace in DashboardView context preparation
Jun 25, 2025
61e261b
Merge pull request #95 from NINAnor/add-responsible-scientist
mortenlyn Jun 25, 2025
4ea4d39
Replace remaining confirmed orders with delivered
omfj Jun 25, 2025
d31a85c
Merge bad migrations (17)
omfj Jun 25, 2025
b268ddf
Merge pull request #104 from NINAnor/omfj/merge-migrations-17
omfj Jun 25, 2025
a4d48ce
Clean up migration history
omfj Jun 25, 2025
6bb8813
Merge pull request #96 from NINAnor/omfj/replace-confirmed-with-deliv…
omfj Jun 25, 2025
24730cc
Enhance dashboard order display with deadline and status; filter urge…
Jun 25, 2025
117ed17
Add admin user to genlab group
omfj Jun 25, 2025
be6e448
Merge remote-tracking branch 'origin/main' into summer25
emilte Jun 26, 2025
0180947
Disable override code. (#59)
emilte Jun 26, 2025
8198afa
Add ANN rules. (#57)
emilte Jun 26, 2025
0ed4399
Run actions on target summer25. (#125)
emilte Jun 26, 2025
334bfa7
Register Permission. (#107)
emilte Jun 26, 2025
85c2eb5
Improve SampleAdmin. (#114)
emilte Jun 26, 2025
a6024f0
Improve ExtractionOrderAdmin. (#118)
emilte Jun 26, 2025
91d1112
Improve AnalysisOrderAdmin. (#122)
emilte Jun 26, 2025
22c61ba
Merge pull request #108 from NINAnor/omfj/squash-migrations
omfj Jun 27, 2025
2d76d59
Add order filter. (#127)
emilte Jun 27, 2025
aaabfcb
Improve EquipmentOrderAdmin. (#129)
emilte Jun 30, 2025
8495bcf
Generalise out of template (#115)
aastabk Jun 30, 2025
844a6bc
Auto-generate fish_id and conditionally include it in csv based on aq…
mortenlyn Jun 30, 2025
538f7c6
Fix typo confirmed -> delivered (#130)
omfj Jun 30, 2025
b417185
Display fish_id in admin. (#134)
emilte Jun 30, 2025
c512e56
Improve SampleMarkerAnalysisAdmin. (#136)
emilte Jun 30, 2025
58a1fb5
Add missing migration. (#140)
emilte Jun 30, 2025
51ae68b
Improve ExtractPlatePositionAdmin. (#138)
emilte Jun 30, 2025
d4d0643
Stop makemigration in entrypoint. (#143)
emilte Jun 30, 2025
8832cbf
Improve SpeciesAdmin. (#148)
emilte Jun 30, 2025
0dee8a4
Improve MarkerAdmin. (#150)
emilte Jun 30, 2025
52ae9f4
Improve AnalysisResultAdmin. (#154)
emilte Jul 1, 2025
d23109d
Improve ExtractionPlateAdmin. (#152)
emilte Jul 1, 2025
50ba051
Update equipment order detail template to clarify buffer/volume colum…
mortenlyn Jul 1, 2025
267d08f
Improve AreaAdmin. (#156)
emilte Jul 1, 2025
81bf44e
Improve LocationAdmin. (#158)
emilte Jul 1, 2025
4af0248
Improve SampleTypeAdmin. (#167)
emilte Jul 1, 2025
03c8d43
Improve GenrequestAdmin. (#160)
emilte Jul 1, 2025
dbdb21b
Improve EquipmentTypeAdmin. (#169)
emilte Jul 1, 2025
7b25b2b
Improve EquimentOrderQuantityAdmin. (#171)
emilte Jul 1, 2025
43dec1f
Assign staff to order (#165)
omfj Jul 2, 2025
da6e9b6
Improve EquipmentBufferAdmin. (#173)
emilte Jul 2, 2025
5b7da41
Add verbose_name and help_text to expected_delivery_date attribute in…
mortenlyn Jul 3, 2025
2398cef
Add status columns and batch update for samples (#141)
mortenlyn Jul 4, 2025
53934a8
Merge remote-tracking branch 'origin/main' into summer25
emilte Jul 4, 2025
4f5f0e1
Add mypy alias. (#193)
emilte Jul 4, 2025
8a1edb0
Now shown the number of samples in an order, not the samples in the p…
aastabk Jul 7, 2025
abaee70
Refactor SampleLabView to use a dedicated success URL for redirection…
mortenlyn Jul 7, 2025
a626b2c
180 able to prioritize samples internally (#183)
aastabk Jul 7, 2025
a558293
196 make a user interface for generating genlab ids (#197)
aastabk Jul 7, 2025
f9239d1
Always an option to convert to draft (#199)
aastabk Jul 7, 2025
78ca1c3
Add button to link from extraction order to related analysis order (#…
mortenlyn Jul 7, 2025
2376f28
Add urgent, new and assigned orders to dashboard (#178)
omfj Jul 7, 2025
2ef09b0
Able to change status and convert to draft for analysis orders (#202)
aastabk Jul 7, 2025
01713f6
Add is_seen and is_prioritized to order (#204)
omfj Jul 7, 2025
fdbbc92
Mark orders as seen and prioritized from the dashboard (#191)
omfj Jul 7, 2025
3a7e7ef
Add link to related extraction order analysis order (#205)
mortenlyn Jul 7, 2025
3d7de82
Add column note in sample status page (#194)
mortenlyn Jul 7, 2025
47e6391
Fix conditional rendering for extraction order link in analysis order…
mortenlyn Jul 7, 2025
6e0d06c
Display markers on dashboard (#207)
omfj Jul 8, 2025
28636f8
Fix bug where dropdown in header is disabled in sample status page (#…
mortenlyn Jul 8, 2025
6060512
Reorganize project detail layout and conditional rendering for verifi…
mortenlyn Jul 8, 2025
8206b85
Get sample count for analysis (#216)
omfj Jul 8, 2025
21118da
Remove redundant prefetch (#219)
omfj Jul 8, 2025
97232f0
Make responsible staff blank (#220)
omfj Jul 8, 2025
e5b844f
Add description to my orders (#221)
omfj Jul 8, 2025
2df47b5
Stack dashboard on smaller screens (#224)
omfj Jul 8, 2025
f7ef331
Display orders assigned to user (#223)
omfj Jul 8, 2025
b141c12
Assign statuses with lower weight than selected (#226)
omfj Jul 9, 2025
d230dbe
Add table for draft orders to dashboard (#227)
omfj Jul 9, 2025
b9da6bb
203 add button to check new orders if you are responsible analysis an…
aastabk Jul 9, 2025
bf2f691
Made a workaround to not have a buggy upper flag in samples list. (#228)
aastabk Jul 9, 2025
3c5af4a
BREAKING CHANGE - remove the use of database sequences (#230)
nicokant Jul 10, 2025
159583d
Able to add staff to genrequest (#244)
aastabk Jul 11, 2025
5d3d77b
Column for isolation method sample status (#243)
mortenlyn Jul 11, 2025
ee8c457
Add 'type' column to SampleStatusTable and update back button link in…
mortenlyn Jul 11, 2025
72e6719
fix: remove select related of nullable field
nicokant Jul 14, 2025
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
2 changes: 2 additions & 0 deletions aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ alias dpcli_prod="docker compose --profile prod"
alias djcli_dev="docker compose exec -it django-dev ./src/manage.py"
alias djcli_prod="docker compose exec -it django ./src/manage.py"

alias run-mypy="uv run mypy ."

alias deps-sync="uv sync"
alias deps-sync-prod="uv sync --profile prod --no-dev"
alias deps-outdated="uv tree --outdated --depth 1"
Expand Down
38 changes: 37 additions & 1 deletion src/fixtures/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,41 @@
"groups": [1],
"user_permissions": []
}
},
{
"model": "users.user",
"pk": 2,
"fields": {
"password": "pbkdf2_sha256$180000$10jDVElGx6nr$0o2RbVZhcE/BAHG6pCvAX4DI8V4mjIHgnN0pdNOKkr8=",
"last_login": "2023-05-27T09:22:46.831Z",
"is_superuser": false,
"first_name": "Kari",
"last_name": "Nordmann",
"email": "kari.nordmann@norge.no",
"is_staff": true,
"is_active": true,
"date_joined": "2023-05-27T08:35:08.845Z",
"groups": [
1
],
"user_permissions": []
}
]
},
{
"model": "users.user",
"pk": 3,
"fields": {
"password": "pbkdf2_sha256$180000$10jDVElGx6nr$0o2RbVZhcE/BAHG6pCvAX4DI8V4mjIHgnN0pdNOKkr8=",
"last_login": "2023-05-27T09:22:46.831Z",
"is_superuser": false,
"first_name": "Ola",
"last_name": "Nordmann",
"email": "ola.nordmann@norge.no",
"is_staff": true,
"is_active": true,
"date_joined": "2023-05-27T08:35:08.845Z",
"groups": [],
"user_permissions": []
}
}
]
25 changes: 22 additions & 3 deletions src/genlab_bestilling/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
ExtractionPlate,
ExtractPlatePosition,
Genrequest,
IsolationMethod,
Location,
LocationType,
Marker,
Organization,
Sample,
SampleMarkerAnalysis,
SampleStatusAssignment,
SampleType,
Species,
)
Expand Down Expand Up @@ -200,9 +202,18 @@ class EquipmentTypeAdmin(ModelAdmin):

@admin.register(EquipmentBuffer)
class EquipmentBufferAdmin(ModelAdmin):
list_display = ["name", "unit"]
list_filter = ["unit"]
search_fields = ["name"]
M = EquipmentBuffer
list_display = [M.name.field.name, M.unit.field.name]

search_help_text = "Search for equipment buffer name"
search_fields = [M.name.field.name]

list_filter = [
(M.name.field.name, unfold_filters.FieldTextFilter),
(M.unit.field.name, unfold_filters.FieldTextFilter),
]
list_filter_submit = True
list_filter_sheet = False


@admin.register(EquimentOrderQuantity)
Expand Down Expand Up @@ -513,3 +524,11 @@ class AnalysisResultAdmin(ModelAdmin):
M.last_modified_at.field.name,
M.created_at.field.name,
]


@admin.register(SampleStatusAssignment)
class SampleStatusAssignmentAdmin(ModelAdmin): ...


@admin.register(IsolationMethod)
class IsolationMethodAdmin(ModelAdmin): ...
196 changes: 0 additions & 196 deletions src/genlab_bestilling/libs/genlabid.py

This file was deleted.

75 changes: 74 additions & 1 deletion src/genlab_bestilling/managers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
from django.db import models
from __future__ import annotations

from typing import TYPE_CHECKING

from django.db import models, transaction
from django.db.models import QuerySet
from django.db.models.expressions import RawSQL
from polymorphic.managers import PolymorphicManager, PolymorphicQuerySet

from capps.users.models import User

if TYPE_CHECKING:
from .models import GIDSequence, Species


class GenrequestQuerySet(models.QuerySet):
def filter_allowed(self, user: User) -> QuerySet:
Expand Down Expand Up @@ -46,6 +54,9 @@ def filter_in_draft(self) -> QuerySet:
)


DEFAULT_SORTING_FIELDS = ["name_as_int", "name"]


class SampleQuerySet(models.QuerySet):
def filter_allowed(self, user: User) -> QuerySet:
"""
Expand All @@ -61,6 +72,48 @@ def filter_in_draft(self) -> QuerySet:
order__status=self.model.OrderStatus.DRAFT
)

@transaction.atomic
def generate_genlab_ids(
self,
order_id: int,
sorting_order: list[str] | None = DEFAULT_SORTING_FIELDS,
selected_samples: list[int] | None = None,
) -> None:
"""
genlab ids given a certain order_id, sorting order and sample ids

"""

# Lock the samples
samples = (
self.select_related("species", "order")
.filter(order_id=order_id, genlab_id__isnull=True)
.select_for_update()
)

if selected_samples:
samples = samples.filter(id__in=selected_samples)

if sorting_order == DEFAULT_SORTING_FIELDS:
# create an annotation containg all integer values
# of "name", so that it's possible to sort numerically and alphabetically
samples = samples.annotate(
name_as_int=RawSQL(
r"substring(%s from '^\d+$')::int",
params=["name"],
output_field=models.IntegerField(),
)
).order_by(*sorting_order)
else:
samples = samples.order_by(*sorting_order)

updates = []
for sample in samples:
sample.generate_genlab_id(commit=False)
updates.append(sample)

self.bulk_update(updates, ["genlab_id"])


class SampleAnalysisMarkerQuerySet(models.QuerySet):
def filter_allowed(self, user: User) -> QuerySet:
Expand All @@ -76,3 +129,23 @@ def filter_in_draft(self) -> QuerySet:
return self.select_related("order").filter(
order__status=self.model.OrderStatus.DRAFT
)


class GIDSequenceQuerySet(models.QuerySet):
def get_sequence_for_species_year(
self, species: Species, year: int, lock: bool = False
) -> GIDSequence:
"""
Get or creates an ID sequence based on the sample year and species
"""
if lock:
s = self.select_for_update()
else:
s = self

sequence_id, _ = s.get_or_create(
year=year,
species=species,
defaults={"id": f"G{year % 100}{species.code}"},
)
return sequence_id
Loading