def post(self):
     """ handler of dealing with geo info update """
     if self._is_json(self.request.get('geo_data')):
         json_geo_data = json.loads(self.request.get('geo_data'))
         for key in json_geo_data.keys():
             new_geo_info = NewAlbumGeoInfo( id = key )
             new_geo_info.album_id = key
             new_geo_info.album_title = json_geo_data[key]['album_title']
             new_geo_info.album_description = json_geo_data[key]['album_description']
             new_geo_info.album_thumbnail = json_geo_data[key]['album_thumbnail']
             new_geo_info.album_link = json_geo_data[key]['album_link']
             new_geo_info.album_lat = json_geo_data[key]['album_lat']
             new_geo_info.album_lng = json_geo_data[key]['album_lng']
             
             new_geo_info.put()
             
         processing_status = 'success'
         
     else:
         processing_status = 'received variable is not in JSON format'
     
     # ajax response
     ajax_response = {'processing_status': processing_status}
     self.response.out.headers['Content-Type'] = 'text/json'
     self.response.out.write(json.dumps(ajax_response))
    def post(self):
        """ handler of dealing with geo info update """
        if self._is_json(self.request.get("geo_data")):
            json_geo_data = json.loads(self.request.get("geo_data"))
            for key in json_geo_data.keys():
                new_geo_info = NewAlbumGeoInfo(id=key)
                new_geo_info.album_id = key
                new_geo_info.album_title = json_geo_data[key]["album_title"]
                new_geo_info.album_description = json_geo_data[key]["album_description"]
                new_geo_info.album_thumbnail = json_geo_data[key]["album_thumbnail"]
                new_geo_info.album_link = json_geo_data[key]["album_link"]
                new_geo_info.album_lat = json_geo_data[key]["album_lat"]
                new_geo_info.album_lng = json_geo_data[key]["album_lng"]

                new_geo_info.put()

            processing_status = "success"

        else:
            processing_status = "received variable is not in JSON format"

        # ajax response
        ajax_response = {"processing_status": processing_status}
        self.response.out.headers["Content-Type"] = "text/json"
        self.response.out.write(json.dumps(ajax_response))
 def get(self):
     """ financial dispatcher """
     albums_geo_info = NewAlbumGeoInfo.query()
     
     #check if query is empty
     if albums_geo_info.count() <= 0:
         albums_geo_info = None
     
     template_values = {}
     template_values.update({'title':u'柯在陽光下', 'albums_geo_info': albums_geo_info})
     self.render_template(dict_html_ref.financial, template_values)
 def get(self):
     """ albums dispatcher collect the albums geo info and send to front-end """
     template_values = {}
     albums_geo_info = NewAlbumGeoInfo.query()
     
     #check if query is empty
     if albums_geo_info.count() <= 0:
         albums_geo_info = None
     
     template_values.update({'title':u'柯文哲照片集', 'albums_geo_info': albums_geo_info})
     self.render_template(dict_html_ref.albums, template_values)