Add backend support for zone tooltips

This commit is contained in:
Dana Lambert 2021-12-13 11:56:14 +13:00
parent 02b6f51435
commit 1d54abca6a
3 changed files with 24 additions and 1 deletions

View file

@ -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),
),
]

View file

@ -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 ""

View file

@ -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)