Modify models for new zone selection method
This commit is contained in:
parent
36746729ec
commit
8575b7e1ab
2 changed files with 30 additions and 15 deletions
27
backend/right_tree/api/migrations/0010_auto_20211201_2155.py
Normal file
27
backend/right_tree/api/migrations/0010_auto_20211201_2155.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 3.2.8 on 2021-12-01 21:55
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('api', '0009_alter_plant_options'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='zone',
|
||||
name='habitat',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='zones', to='api.habitat'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='zone',
|
||||
name='related_svg_segment',
|
||||
field=models.CharField(blank=True, max_length=20, null=True),
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='ZoneImageSegment',
|
||||
),
|
||||
]
|
|
@ -80,8 +80,11 @@ class Zone(models.Model):
|
|||
name = models.CharField(max_length=50)
|
||||
variant = models.CharField(null=True, blank=True, max_length=50)
|
||||
refined_variant = models.CharField(null=True, blank=True, max_length=100)
|
||||
habitat = models.ForeignKey(
|
||||
Habitat, blank=True, null=True, on_delete=models.CASCADE, related_name='zones')
|
||||
redirect_habitat = models.ForeignKey(
|
||||
Habitat, blank=True, null=True, on_delete=models.CASCADE, related_name='zone_redirects')
|
||||
related_svg_segment = models.CharField(null=True, blank=True, max_length=20)
|
||||
ignore_soil_order_filter = models.BooleanField(default=False)
|
||||
ignore_location_filter = models.BooleanField(default=False)
|
||||
|
||||
|
@ -94,21 +97,6 @@ class Zone(models.Model):
|
|||
ordering = ['name', 'variant', 'refined_variant', 'id']
|
||||
|
||||
|
||||
class ZoneImageSegment(models.Model):
|
||||
zone = models.ForeignKey(
|
||||
Zone, on_delete=models.CASCADE, related_name='image_segments')
|
||||
habitat_image = models.ForeignKey(
|
||||
HabitatImage, on_delete=models.CASCADE, related_name='image_segments')
|
||||
segment_order = models.PositiveIntegerField(default=0)
|
||||
segment_percentage_width = models.FloatField(default=0)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.habitat_image.name}, {self.zone}"
|
||||
|
||||
class Meta:
|
||||
ordering = ['segment_order', 'id']
|
||||
|
||||
|
||||
class Plant(models.Model):
|
||||
name = models.CharField(unique=True, max_length=50)
|
||||
commonname = models.CharField(null=True, blank=True, max_length=200)
|
||||
|
|
Loading…
Reference in a new issue