maps: sort marker alphabetically (#19065)

This commit is contained in:
Frédéric Péters 2017-09-30 12:39:31 +02:00
parent 2c9cc327a0
commit f18a8ccda6
1 changed files with 7 additions and 0 deletions

View File

@ -15,6 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django import forms
from django.utils.encoding import force_text
from .models import MapLayer
@ -33,3 +35,8 @@ class MapLayerForm(forms.ModelForm):
widgets = {'marker_colour': forms.TextInput(attrs={'type': 'color'}),
'icon_colour': forms.TextInput(attrs={'type': 'color'})
}
def __init__(self, *args, **kwargs):
super(MapLayerForm, self).__init__(*args, **kwargs)
self.fields['icon'].choices = list(
sorted(self.fields['icon'].choices, key=lambda x: force_text(x[1])))