def get(self): error = urllib.unquote(self.request.get('error')) startDate = get_startDay() reports = Report().all().filter('title', title) reports.order('-date') reports.filter('date >' ,startDate) template_values = { 'title' : title, 'e_msg':error, 'reports': simplejson.dumps([r.to_dict() for r in reports]), 'startDate':startDate } path = os.path.join(os.path.dirname(__file__), 'index.html') self.response.out.write(template.render(path, template_values))
def get(self,title): startDate = get_startDay() reports = Report().all() reports.filter('title', title) reports.order('-date') reports.filter('date >' ,startDate) feed = FeedFMSParser() final_report = feed.list_items() final_report += [r.to_dict() for r in reports] json = simplejson.dumps(final_report) self.response.headers.add_header('content-type', 'application/json', charset='utf-8') self.response.out.write(json)
def post(self): request = self.request report = Report() #try: name = urllib.unquote(self.request.get('name')) water = urllib.unquote(self.request.get('water')) road = urllib.unquote(self.request.get('road')) text = urllib.unquote(self.request.get('text')) lat = urllib.unquote(self.request.get('lat')) lng = urllib.unquote(self.request.get('lng')) report.title = title report.name = name report.lat = float(lat) report.lng = float(lng) report.water = int(water) report.text = text report.road = bool(road) report.put() # except Exception, e: #self.redirect('/ThaiFlood2011/?error=Error, %s'%e) error = urllib.unquote(self.request.get('error')) startDate = get_startDay() reports = Report().all().filter('title', title) reports.order('-date') reports.filter('date >' ,startDate) template_values = { 'title' : title, 'e_msg':error, 'reports': simplejson.dumps([r.to_dict() for r in reports]), 'startDate':startDate } path = os.path.join(os.path.dirname(__file__), 'index.html') self.response.out.write(template.render(path, template_values))