Ejemplo n.º 1
0
 def geocode(self, postcode):
     data = geocode(postcode)
     if data:
         self.constituency = data['constituency']
         self.location = Point(
             data['wgs84_lon'],
             data['wgs84_lat'],
         )
Ejemplo n.º 2
0
 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")
         )
Ejemplo n.º 3
0
 def geocode(self, postcode):
     data = geocode(postcode)
     if data:
         self.constituency = data['constituency']
         self.location = Point(
             data['wgs84_lon'],
             data['wgs84_lat'],
         )
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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"))
Ejemplo n.º 8
0
 def geocode(self, postcode):
     data = geocode(postcode)
     if data:
         self.constituency = data["constituency"]
         self.location = Point(data["wgs84_lon"], data["wgs84_lat"],)