diff --git a/backend/right_tree/api/migrations/0013_zone_tooltiptext.py b/backend/right_tree/api/migrations/0013_zone_tooltiptext.py new file mode 100644 index 0000000..5154c69 --- /dev/null +++ b/backend/right_tree/api/migrations/0013_zone_tooltiptext.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.8 on 2021-12-12 22:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0012_alter_plant_maxheight'), + ] + + operations = [ + migrations.AddField( + model_name='zone', + name='tooltipText', + field=models.CharField(blank=True, max_length=500, null=True), + ), + ] diff --git a/backend/right_tree/api/models.py b/backend/right_tree/api/models.py index 58da42a..14f5c8a 100644 --- a/backend/right_tree/api/models.py +++ b/backend/right_tree/api/models.py @@ -87,6 +87,11 @@ class Zone(models.Model): 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) + tooltipText = models.CharField(null=True, blank=True, max_length=500) + + @property + def tooltip_display_text(self): + return self.tooltipText if self.tooltipText is not None else str(self) def __str__(self): refined_variant_str = f", {self.refined_variant}" if self.refined_variant is not None else "" diff --git a/backend/right_tree/api/serializers.py b/backend/right_tree/api/serializers.py index 6ff0ec4..52ddd36 100644 --- a/backend/right_tree/api/serializers.py +++ b/backend/right_tree/api/serializers.py @@ -62,7 +62,7 @@ class ZoneSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Zone fields = ['id', 'name', 'variant', - 'refined_variant', 'habitat', 'related_svg_segment', 'redirect_habitat', 'ignore_soil_order_filter', 'ignore_location_filter'] + 'refined_variant', 'habitat', 'related_svg_segment', 'redirect_habitat', 'ignore_soil_order_filter', 'ignore_location_filter', 'tooltip_display_text'] class LocationDetailsSerializer(serializers.Serializer): ecologic_1 = serializers.CharField(max_length=50) ecologic_2 = serializers.CharField(max_length=50)