overlay api

This commit is contained in:
Gwendolyn 2024-12-16 11:36:43 +01:00
parent 1cfcf7a5e1
commit 6b494810cc
3 changed files with 34 additions and 4 deletions

View file

@ -0,0 +1,28 @@
# Generated by Django 5.1.3 on 2024-12-16 10:23
from django.db import migrations, models
def change_empty_to_null(apps, schema_editor):
DataOverlay = apps.get_model('mapdata', 'DataOverlay')
DataOverlay.objects.filter(fill_color='').update(fill_color=None)
DataOverlay.objects.filter(stroke_color='').update(stroke_color=None)
class Migration(migrations.Migration):
dependencies = [
('mapdata', '0116_waytype_avoid_by_default_alter_waytype_description'),
]
operations = [
migrations.AlterField(
model_name='dataoverlay',
name='fill_color',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='default fill color'),
),
migrations.AlterField(
model_name='dataoverlay',
name='stroke_color',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='default stroke color'),
),
migrations.RunPython(change_empty_to_null, migrations.RunPython.noop),
]

View file

@ -14,9 +14,9 @@ from c3nav.mapdata.utils.json import format_geojson
class DataOverlay(TitledMixin, AccessRestrictionMixin, models.Model):
description = models.TextField(blank=True, verbose_name=_('Description'))
stroke_color = models.TextField(blank=True, null=True, verbose_name=_('default stroke color'))
stroke_color = models.CharField(max_length=255, blank=True, null=True, verbose_name=_('default stroke color'))
stroke_width = models.FloatField(blank=True, null=True, verbose_name=_('default stroke width'))
fill_color = models.TextField(blank=True, null=True, verbose_name=_('default fill color'))
fill_color = models.CharField(max_length=255, blank=True, null=True, verbose_name=_('default fill color'))
pull_url = models.URLField(blank=True, null=True, verbose_name=_('pull URL'))
pull_headers: dict[str, str] = SchemaField(schema=dict[str, str], null=True,
verbose_name=_('headers for pull http request (JSON object)'))

View file

@ -365,7 +365,10 @@ class DataOverlaySchema(TitledSchema, DjangoModelSchema):
"""
Represents a collection of geometries to be displayed as an optional overlay to the map.
"""
pass
description: Optional[str]
stroke_color: Optional[str]
stroke_width: Optional[float]
fill_color: Optional[str]
@ -384,7 +387,6 @@ class DataOverlayFeatureSchema(TitledSchema, WithGeometrySchema, DjangoModelSche
point_icon: Optional[str]
external_url: Optional[str]
extra_data: Optional[dict[str, str]]
# TODO
class SourceSchema(WithAccessRestrictionSchema, DjangoModelSchema):