Skip to content

Commit 355ffd4

Browse files
committed
Add type to isolation method
1 parent 57aad3a commit 355ffd4

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generated by Django 5.2.3 on 2025-07-22 10:26
2+
3+
from django.db import migrations, models
4+
from django.db.migrations.state import StateApps
5+
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
6+
7+
8+
def delete_isolation_methods(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor):
9+
IsolationMethod = apps.get_model("genlab_bestilling", "IsolationMethod")
10+
11+
IsolationMethod.objects.all().delete()
12+
13+
14+
def reverse_delete_isolation_methods(
15+
apps: StateApps, schema_editor: BaseDatabaseSchemaEditor
16+
):
17+
pass
18+
19+
20+
class Migration(migrations.Migration):
21+
dependencies = [
22+
(
23+
"genlab_bestilling",
24+
"0030_samplemarkeranalysis_has_pcr_and_more",
25+
),
26+
]
27+
28+
operations = [
29+
migrations.RunPython(
30+
delete_isolation_methods,
31+
reverse_delete_isolation_methods,
32+
),
33+
migrations.RemoveField(model_name="isolationmethod", name="species"),
34+
migrations.AddField(
35+
model_name="isolationmethod",
36+
name="type",
37+
field=models.ForeignKey(
38+
to="genlab_bestilling.sampletype",
39+
on_delete=models.CASCADE,
40+
related_name="type_isolation_methods",
41+
help_text="The sample type this isolation method is related to.",
42+
),
43+
),
44+
]

src/genlab_bestilling/models.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -806,13 +806,12 @@ def __str__(self) -> str:
806806

807807

808808
class IsolationMethod(models.Model):
809-
name = models.CharField(max_length=255, unique=False)
810-
species = models.ForeignKey(
811-
f"{an}.Species",
809+
name = models.CharField(max_length=255)
810+
type = models.ForeignKey(
811+
f"{an}.SampleType",
812812
on_delete=models.CASCADE,
813-
related_name="species_isolation_methods",
814-
help_text="The species this isolation method is related to.",
815-
default=None,
813+
related_name="type_isolation_methods",
814+
help_text="The sample type this isolation method is related to.",
816815
)
817816

818817
def __str__(self) -> str:

0 commit comments

Comments
 (0)