def get(self): """get() - when a http request comes in (from a priviliged user), check each orchestra's events page and decide whether they are busy or not!""" for orch in Orchestra.orchs: orch_entity = Orchestra.get_by_id(orch) if orch_entity: eventinfo = runupdate(orch) if eventinfo: time = eventinfo[0] location = eventinfo[1] detail = eventinfo[2] if location == None: orch_entity.location = Orchestra.orchs[orch]["home"] detail = """ <em>Could not findthe location listed</em><br /> """+detail else: orch_entity.location = ndb.GeoPt( location[0], location[1]) orch_entity.time = time orch_entity.detail = detail orch_entity.put() return self.response.set_status(200)
def get(self): """Sorts and returns our webpage on get requests, with all the Orchestras and their details from the NDB all formatted nicely with Jinja2""" for orch in Orchestra.orchs.keys(): orch_entity = Orchestra.get_by_id(orch) if not orch_entity: geo_loc = Orchestra.orchs[orch]["home"] print orch, geo_loc gig_time = datetime.datetime.now() orch_entity = Orchestra(id=orch, location=geo_loc, time=gig_time) orch_entity.put() orch_results = Orchestra.query().fetch() template_values = {"orchs": orch_results, "orchlist": Orchestra.orchs} template = self.jinja_env.get_template("index.html") self.response.write(template.render(template_values))