def get_destination(self): destination_address = self.clean_data['destination_address'] if GoogleMaps.is_valid_address(destination_address): return Location.get_by_address(destination_address, create=True) else: return None
def get_source(self): source_address = self.clean_data['source_address'] if GoogleMaps.is_valid_address(source_address): return Location.get_by_address(source_address, create=True) else: return None
def get(self): # -------------------------------------------------------------------- # Retrive Session Info and GET Data # -------------------------------------------------------------------- # Session Values current_user = RoadMateUser.get_current_user() # Request Values target_location_id = self.get_request_parameter('id', converter=int, default=None) # Datastore Values target_location = Location.get_by_id(target_location_id) # -------------------------------------------------------------------- # Validate Request # -------------------------------------------------------------------- # if the target ride does not exist in the datastore, then redirect # the user back to the home page. if target_location is None: self.error(404) return # -------------------------------------------------------------------- # Generate and Store Template Values # -------------------------------------------------------------------- template_values = super(ViewLocationPageHandler, self ).generate_template_values(self.request.url) template_values['target_location'] = target_location template_values['googlemaps_key'] = GoogleMaps.get_key() # -------------------------------------------------------------------- # Render and Serve Template # -------------------------------------------------------------------- page_path = os.path.join(os.path.dirname(__file__), "location_view.html") self.response.out.write(template.render(page_path, template_values))