Added filter_distination to HistoryForm
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sun, 17 Apr 2011 11:23:39 +0000 (11:23 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sun, 17 Apr 2011 11:23:39 +0000 (11:23 +0000)
bin/djais/views.py

index e5d568872ff5a10859752b66df359f5d201508cc..96b0b0c833f9c5d93e8909a6ca4d9e46ea217279 100644 (file)
@@ -73,7 +73,6 @@ class VesselSearchForm(forms.Form):
     flag = forms.ChoiceField(choices=country_choices(), required=False)
     destination = forms.CharField(max_length=20, required=False)
 
-
     def clean(self):
         cleaned_data = self.cleaned_data
         for value in cleaned_data.values():
@@ -175,6 +174,7 @@ class HistoryForm(forms.Form):
         choices=[ (u'', u'(Not filtered)') ] + [ (fn[1], fn[0]) for fn in list_areas() ] )
     filter_sog_le = forms.FloatField(required=False, label=u'Only if speed ≤ (knots)')
     filter_sog_ge = forms.FloatField(required=False, label=u'Only if speed ≥ (knots)')
+    filter_destination = forms.CharField(required=False, label=u'Only if destination starts with', max_length=20, help=u'Use AIS upper case letters')
 
     def clean_start_date(self):
         period_type = self.cleaned_data.get('period_type', None)
@@ -212,6 +212,7 @@ class HistoryForm(forms.Form):
         '''
         Must not be called unless is_valid
         Returns (command, extension)
+        FIXME escape!
         '''
         data = self.cleaned_data
         format = data['format']
@@ -259,6 +260,10 @@ class HistoryForm(forms.Form):
         if filter_sog_ge:
             command += u' --filter-sog-ge ' + unicode(filter_sog_ge)
 
+        filter_destination = data.get('filter_destination', None)
+        if filter_destination:
+            command += u' --filter-destination \'' + filter_destination + u'\''
+
         return command, extension