def post(self): ward_code = self.request.get('ward_code') district_code = self.request.get('district_code') county_code = self.request.get('county_code') counties = County.all().filter('code =', county_code).fetch(limit=1) if ward_code: districts = District.all().filter('code =', district_code).filter('county =', counties[0].key()).fetch(limit=1) ward = Ward( name=self.request.get('name'), code=ward_code, full_code=county_code + district_code + ward_code, district=districts[0], ) ward.put() elif district_code: district = District( name=self.request.get('name'), code=district_code, county=counties[0], ) district.put() else: county = County( name=self.request.get('name'), code=county_code, ) county.put()
def post(self): ward = Ward( name=self.request.get('name'), district=self.request.get('district'), county=self.request.get('county'), urban_arts_eclectic=float(self.request.get('urban_arts_eclectic')), traditional_culture_vultures=float(self.request.get('traditional_culture_vultures')), fun_fashion_and_friends=float(self.request.get('fun_fashion_and_friends')), mature_explorers=float(self.request.get('mature_explorers')), dinner_and_a_show=float(self.request.get('dinner_and_a_show')), family_and_community_focused=float(self.request.get('family_and_community_focused')), bedroom_djs=float(self.request.get('bedroom_djs')), mid_life_hobbyists=float(self.request.get('mid-life_hobbyists')), retired_arts_and_crafts=float(self.request.get('retired_arts_and_crafts')), time_poor_dreamers=float(self.request.get('time_poor_dreamers')), a_quiet_pint_with_the_match=float(self.request.get('a_quiet_pint_with_the_match')), older_and_home_bound=float(self.request.get('older_and_home_bound')) ) ward.put()
def post(self): postcode = self.request.get('postcode').replace(' ', '') latitude = self.request.get('latitude') longitude = self.request.get('longitude') ward_code = self.request.get('ward_code') district_code = self.request.get('district_code') county_code = self.request.get('county_code') full_code = county_code + district_code + ward_code wards = Ward.all().filter('full_code =', full_code).fetch(limit=1) postcode_obj = Postcode( postcode = postcode, latitude = float(latitude), longitude = float(longitude), ward = wards[0] if wards else None, ) postcode_obj.put()
def get(self): if self.request.get('name'): wards = Ward.all().filter('name =', self.request.get('name')).fetch(limit=1) self.render('display', {'ward': wards[0] }) else: self.render('display')
def get_ward(full_code): wards = Ward.all().filter('full_code =', full_code).fetch(limit=1) return wards[0] if wards else None