Sort areas by name
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sun, 17 Apr 2011 09:47:30 +0000 (09:47 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sun, 17 Apr 2011 09:47:30 +0000 (09:47 +0000)
Show filter area input in history form

bin/area.py
bin/djais/views.py

index fc5324c9ec3801d6cc46095dcef77e3b9b35e1e1..23a7cc225030e9ce5338455fd6d75465d4a34235 100644 (file)
@@ -127,6 +127,8 @@ def list_areas():
         if not filename.endswith(u'.kml'):
             continue # ignore non-kml files
         results.append((filename[:-4], AREA_DIR+filename))
+    # sort by name
+    results.sort(cmp=lambda a1,a2: cmp(a1[0], a2[0]))
     return results
     
 if __name__ == '__main__':
index 47b6b6be1b7b8641e0baabf4bbf2afd02dde098d..0fef29eb8223438c8faafdeac1ac269c8d3b5dd1 100644 (file)
@@ -25,6 +25,7 @@ from django.utils.safestring import mark_safe
 
 from decoratedstr import remove_decoration
 
+from ais.areas import list_areas
 from ais.djais.basicauth import http_authenticate
 from ais.djais.models import *
 from ais.show_targets_ships import format_fleet, kml_to_kmz
@@ -170,6 +171,7 @@ class HistoryForm(forms.Form):
     duration = SecondsField(required=False, label='Period length', initial=7*86400)
     end_date = forms.DateTimeField(required=False, widget=AisCalendarWidget(attrs={'class':'vDateField'}))
     grain = SecondsField(label='One position every', initial=3600)
+    filter_area = forms.ChoiceField(required=False, label='Only in area (not implemented)', choices=list_areas())
 
     def clean_start_date(self):
         period_type = self.cleaned_data.get('period_type', None)