def geocode(self, postcode): data = geocode(postcode) if data: self.constituency = data['constituency'] self.location = Point( data['wgs84_lon'], data['wgs84_lat'], )
def clean(self): cleaned_data = super(ConstituencyLookupForm, self).clean() pcode = cleaned_data.get("postcode") self.location = geocode(pcode) if not self.location: raise forms.ValidationError( _("That postcode was not found. Please try another") )
def clean(self): data = super(PostcodeForm, self).clean() if not data.get('postcode'): raise forms.ValidationError("Please enter a full valid UK postcode") postcode = self.cleaned_data['postcode'] self.geo_data = geocode(postcode) if not self.geo_data or 'constituency' not in self.geo_data: raise forms.ValidationError("Please enter a full valid UK postcode") data['constituency'] = self.geo_data['constituency'] data['wgs84_lon'] = self.geo_data['wgs84_lon'] data['wgs84_lat'] = self.geo_data['wgs84_lat'] return data
def clean_postcode(self): postcode = self.cleaned_data['postcode'] self.geo_data = geocode(postcode) if not self.geo_data or 'constituency' not in self.geo_data: raise forms.ValidationError("Please enter a full valid UK postcode") return postcode
def clean(self): cleaned_data = super(ConstituencyLookupForm, self).clean() pcode = cleaned_data.get("postcode") self.location = geocode(pcode) if not self.location: raise forms.ValidationError(_("That ZIP Code was not found. Please try another"))
def geocode(self, postcode): data = geocode(postcode) if data: self.constituency = data["constituency"] self.location = Point(data["wgs84_lon"], data["wgs84_lat"],)