diff options
Diffstat (limited to 'chimere/forms.py')
-rw-r--r-- | chimere/forms.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/chimere/forms.py b/chimere/forms.py index eccc7c5..a8aa824 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -105,6 +105,25 @@ class ImporterAdminForm(forms.ModelForm): 'filtr': forms.TextInput(attrs={'size': 80}), } + def clean(self): + ''' + 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']: + raise forms.ValidationError(_(u"Shapefiles must be provided in a "\ + u"zipped archive.")) + if self.cleaned_data['source'] and \ + self.cleaned_data['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']: + raise forms.ValidationError(_(u"You have to set \"source\" or " + u"\"source file\".")) + return self.cleaned_data + class CategoryAdminForm(forms.ModelForm): """ Main form for categories |