From 61b25ede1399d63f9b14f605cdac617fc4dc15da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Cant=C3=B9?= Date: Fri, 21 Jun 2024 13:58:57 +0200 Subject: [PATCH] remove required on fields --- src/genlab_bestilling/admin.py | 4 +-- ...ple_area_alter_sample_location_and_more.py | 32 +++++++++++++++++++ src/genlab_bestilling/models.py | 8 +++-- 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/genlab_bestilling/migrations/0008_remove_sample_area_alter_sample_location_and_more.py diff --git a/src/genlab_bestilling/admin.py b/src/genlab_bestilling/admin.py index 2176540..d412af9 100644 --- a/src/genlab_bestilling/admin.py +++ b/src/genlab_bestilling/admin.py @@ -127,7 +127,7 @@ class EquipmentOrderAdmin(ModelAdmin): class SampleInline(admin.StackedInline): model = Sample - autocomplete_fields = ["species", "markers", "area", "location", "type"] + autocomplete_fields = ["species", "markers", "location", "type"] @admin.register(AnalysisOrder) @@ -152,4 +152,4 @@ class SampleAdmin(ModelAdmin): search_fields = [] readonly_fields = ["order"] - autocomplete_fields = ["species", "markers", "area", "location", "type"] + autocomplete_fields = ["species", "markers", "location", "type"] diff --git a/src/genlab_bestilling/migrations/0008_remove_sample_area_alter_sample_location_and_more.py b/src/genlab_bestilling/migrations/0008_remove_sample_area_alter_sample_location_and_more.py new file mode 100644 index 0000000..47eaaa1 --- /dev/null +++ b/src/genlab_bestilling/migrations/0008_remove_sample_area_alter_sample_location_and_more.py @@ -0,0 +1,32 @@ +# Generated by Django 5.0.6 on 2024-06-21 11:58 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("genlab_bestilling", "0007_alter_order_status"), + ] + + operations = [ + migrations.RemoveField( + model_name="sample", + name="area", + ), + migrations.AlterField( + model_name="sample", + name="location", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.PROTECT, + to="genlab_bestilling.location", + ), + ), + migrations.AlterField( + model_name="sample", + name="notes", + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/src/genlab_bestilling/models.py b/src/genlab_bestilling/models.py index 2c953c0..31aee16 100644 --- a/src/genlab_bestilling/models.py +++ b/src/genlab_bestilling/models.py @@ -181,10 +181,12 @@ class Sample(models.Model): species = models.ForeignKey("Species", on_delete=models.PROTECT) markers = models.ManyToManyField("Marker") date = models.DateField() - notes = models.TextField() + notes = models.TextField(null=True, blank=True) pop_id = models.CharField(max_length=150) - area = models.ForeignKey("Area", on_delete=models.PROTECT) - location = models.ForeignKey("Location", on_delete=models.PROTECT) + # area = models.ForeignKey("Area", on_delete=models.PROTECT) + location = models.ForeignKey( + "Location", on_delete=models.PROTECT, null=True, blank=True + ) volume = models.FloatField(null=True, blank=True) # plate