From 5db6ae2fc14ebbec4b52151c7250ca0bba98bc02 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 14 Nov 2012 17:04:53 +0100 Subject: Fix file form check --- chimere/forms.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/chimere/forms.py b/chimere/forms.py index 2cf463f..2380f3c 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -131,17 +131,17 @@ class ImporterAdminForm(forms.ModelForm): Verify that only one type of source is provided Verify that shapefiles are zipped ''' - if self.cleaned_data['importer_type'] == 'SHP' and \ - not self.cleaned_data['zipped']: + if self.cleaned_data.get('importer_type') == 'SHP' and \ + not self.cleaned_data.get('zipped'): raise forms.ValidationError(_(u"Shapefiles must be provided in a "\ u"zipped archive.")) - if self.cleaned_data['source'] and \ - self.cleaned_data['source_file']: + if self.cleaned_data.get('source') and \ + self.cleaned_data.get('source_file'): raise forms.ValidationError(_(u"You have to set \"source\" or " u"\"source file\" but not both.")) - if not self.cleaned_data['source'] and \ - not self.cleaned_data['source_file'] and \ - self.cleaned_data['importer_type'] != 'OSM': + if not self.cleaned_data.get('source') and \ + not self.cleaned_data.get('source_file') and \ + self.cleaned_data.get('importer_type') != 'OSM': raise forms.ValidationError(_(u"You have to set \"source\" or " u"\"source file\".")) return self.cleaned_data -- cgit v1.2.3