summaryrefslogtreecommitdiff
path: root/chimere/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/forms.py')
-rw-r--r--chimere/forms.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/chimere/forms.py b/chimere/forms.py
index 8fafaba..63e8c52 100644
--- a/chimere/forms.py
+++ b/chimere/forms.py
@@ -34,8 +34,8 @@ from django.core.mail import EmailMessage, BadHeaderError
from chimere.models import Marker, Route, PropertyModel, Property, Area,\
News, Category, SubCategory, RouteFile, MultimediaFile, MultimediaType, \
PictureFile, Importer, IMPORTER_CHOICES
-from chimere.widgets import AreaField, PointField, TextareaWidget, \
- TextareaAdminWidget, DatePickerWidget, ImporterChoicesWidget
+from chimere.widgets import AreaField, PointField, TextareaWidget, ImportFiltrWidget,\
+ TextareaAdminWidget, DatePickerWidget, ImporterChoicesWidget, RE_XAPI
from datetime import timedelta, datetime, tzinfo
@@ -98,6 +98,7 @@ class NewsAdminForm(forms.ModelForm):
model = News
class ImporterAdminForm(forms.ModelForm):
+ filtr = forms.CharField(widget=ImportFiltrWidget, required=False)
importer_type = forms.ChoiceField(widget=ImporterChoicesWidget,
choices=[('', '--')]+list(IMPORTER_CHOICES))
class Meta:
@@ -112,6 +113,14 @@ class ImporterAdminForm(forms.ModelForm):
Verify that only one type of source is provided
Verify that shapefiles are zipped
'''
+ if self.cleaned_data.get('importer_type') == 'OSM' and \
+ not self.cleaned_data.get('filtr'):
+ raise forms.ValidationError(_(u"For OSM import you must be "\
+ u"provide a filter. Select an area and node/way filter."))
+ if self.cleaned_data.get('importer_type') == 'OSM' and \
+ not RE_XAPI.match(self.cleaned_data.get('filtr')):
+ raise forms.ValidationError(_(u"For OSM import you must be "\
+ u"provide a filter. Select an area and node/way filter."))
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 "\