Fixed vessel search with empty mmsi
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sun, 7 Nov 2010 19:15:34 +0000 (19:15 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sun, 7 Nov 2010 19:15:34 +0000 (19:15 +0000)
bin/djais/views.py

index 6e070dc3f9b73995d81e31e40d0c3a718c1fccbe..cb5302a89f210245fd8b9dea958d43790c0bf621 100644 (file)
@@ -76,10 +76,11 @@ class VesselSearchForm(forms.Form):
 
     def clean_mmsi(self):
         mmsi = self.cleaned_data['mmsi']
-        try:
-            mmsi = strmmsi_to_mmsi(mmsi)
-        except AssertionError:
-            raise forms.ValidationError("Invalid MMSI")
+        if mmsi:
+            try:
+                mmsi = strmmsi_to_mmsi(mmsi)
+            except AssertionError:
+                raise forms.ValidationError("Invalid MMSI")
         return mmsi