maps: allow editing of slug (#16684)

This commit is contained in:
Frédéric Péters 2017-06-03 22:24:01 +02:00
parent 33c81da7b0
commit 973d75b1f5
4 changed files with 15 additions and 6 deletions

View File

@ -17,10 +17,19 @@
from django import forms
from .models import MapLayer
class MapLayerForm(forms.ModelForm):
class MapNewLayerForm(forms.ModelForm):
class Meta:
model = MapLayer
exclude = ('slug', )
exclude = ('slug', 'cache_duration', 'include_user_identifier')
widgets = {'marker_colour': forms.TextInput(attrs={'type': 'color'}),
'icon_colour': forms.TextInput(attrs={'type': 'color'})
}
class MapLayerForm(forms.ModelForm):
class Meta:
model = MapLayer
fields = '__all__'
widgets = {'marker_colour': forms.TextInput(attrs={'type': 'color'}),
'icon_colour': forms.TextInput(attrs={'type': 'color'})
}

View File

@ -19,7 +19,7 @@ from django.views.generic import (TemplateView, ListView, CreateView,
UpdateView, DeleteView)
from .models import MapLayer
from .forms import MapLayerForm
from .forms import MapNewLayerForm, MapLayerForm
class MapLayerMixin(object):
@ -32,7 +32,7 @@ class ManagerHomeView(MapLayerMixin, ListView):
class LayerAddView(MapLayerMixin, CreateView):
form_class = MapLayerForm
form_class = MapNewLayerForm
template_name = 'maps/map_layer_form.html'

View File

@ -15,7 +15,7 @@ class Migration(migrations.Migration):
fields=[
('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='Slug')),
('slug', models.SlugField(verbose_name='Identifier')),
('geojson_url', models.URLField(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=[(b'house', 'House'), (b'building', 'Building'), (b'hospital', 'Hospital'), (b'ambulance', 'Ambulance'), (b'taxi', 'Taxi'), (b'subway', 'Subway'), (b'wheelchair', 'Wheelchair'), (b'bicycle', 'Bicycle'), (b'car', 'Car'), (b'train', 'Train'), (b'bus', 'Bus'), (b'motorcycle', 'Motorcycle'), (b'truck', 'Truck')])),

View File

@ -55,7 +55,7 @@ ZOOM_LEVELS = [ ('0', _('Whole world')),
class MapLayer(models.Model):
label = models.CharField(_('Label'), max_length=128)
slug = models.SlugField(_('Slug'))
slug = models.SlugField(_('Identifier'))
geojson_url = models.URLField(_('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,