Skip to content

Commit

Permalink
unique genlab id
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed Dec 4, 2024
1 parent 4c5c50d commit 321f782
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/genlab_bestilling/migrations/0012_sample_unique_genlab_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.1.3 on 2024-12-04 10:10

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("genlab_bestilling", "0011_extractplateposition_notes_and_more"),
]

operations = [
migrations.AddConstraint(
model_name="sample",
constraint=models.UniqueConstraint(
fields=("genlab_id",), name="unique_genlab_id"
),
),
]
6 changes: 5 additions & 1 deletion src/genlab_bestilling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ class Sample(models.Model):
def __str__(self) -> str:
return self.genlab_id or f"#SMP_{self.id}"

class Meta:
constraints = [
models.UniqueConstraint(fields=["genlab_id"], name="unique_genlab_id")
]

@property
def has_error(self):
if not all(
Expand Down Expand Up @@ -370,7 +375,6 @@ class ExtractPlatePosition(models.Model):
extracted_at = models.DateTimeField(auto_now=True)
notes = models.CharField(null=True, blank=True)

# TODO: unique position per plate
class Meta:
constraints = [
models.UniqueConstraint(
Expand Down

0 comments on commit 321f782

Please sign in to comment.