maps: allow variables in geojson URLs (#36124)

This commit is contained in:
Frédéric Péters 2019-10-01 08:23:17 +02:00
parent d1c8438d7a
commit a413d67417
3 changed files with 8 additions and 2 deletions

View File

@ -17,7 +17,9 @@
from django import forms
from django.utils.encoding import force_text
from django.utils.text import slugify
from django.utils.translation import ugettext_lazy as _
from combo.data.fields import TemplatableURLField
from .models import MapLayer
@ -26,6 +28,8 @@ class IconRadioSelect(forms.RadioSelect):
class MapNewLayerForm(forms.ModelForm):
geojson_url = TemplatableURLField(label=_('Geojson URL'))
class Meta:
model = MapLayer
exclude = ('slug', 'cache_duration', 'include_user_identifier')
@ -41,6 +45,8 @@ class MapNewLayerForm(forms.ModelForm):
class MapLayerForm(forms.ModelForm):
geojson_url = TemplatableURLField(label=_('Geojson URL'))
class Meta:
model = MapLayer
fields = '__all__'

View File

@ -17,7 +17,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('label', models.CharField(max_length=128, verbose_name='Label')),
('slug', models.SlugField(verbose_name='Identifier')),
('geojson_url', models.URLField(max_length=1024, verbose_name='Geojson URL')),
('geojson_url', models.CharField(max_length=1024, verbose_name='Geojson URL')),
('marker_colour', models.CharField(default=b'#0000FF', max_length=7, verbose_name='Marker colour')),
('icon', models.CharField(blank=True, max_length=32, null=True, verbose_name='Marker icon', choices=ICONS)),
('icon_colour', models.CharField(default=b'#000000', max_length=7, verbose_name='Icon colour')),

View File

@ -96,7 +96,7 @@ class MapLayer(models.Model):
label = models.CharField(_('Label'), max_length=128)
slug = models.SlugField(_('Identifier'))
geojson_url = models.URLField(_('Geojson URL'), max_length=1024)
geojson_url = models.CharField(_('Geojson URL'), max_length=1024)
marker_colour = models.CharField(_('Marker colour'), max_length=7, default='#0000FF')
icon = models.CharField(_('Marker icon'), max_length=32, blank=True, null=True,
choices=ICONS)