def get_all_user_events(self, u_id): events_list = [] results = Attendings.query(Attendings.user_id == u_id) for res in results: if self.get_event_details(res.event_id) is not None: events_list.append(self.get_event_details(res.event_id)) return json.dumps(events_list)
def get(self): self.response.write('Welcome to attender server! Here is a cron job for pulling events from sorces: meetup.com and evenbrite.com') ev = Event() at = Attendings() logging.info("Adding new events to DataStore") results = self.obj.request_events(radius="25") logging.info("Events added: {}".format(results)) logging.info("Deleting old events from DataStore") #Delete passed events qe = ev.return_all_events() results = qe.filter(Event.date < datetime.now()) for res in results: logging.info(str(res.key.id())) old_attending = Attendings.query(Attendings.event_id == int(res.key.id())).get() logging.info("query {}".format(old_attending)) if old_attending is not None: old_attending.key.delete() res.key.delete() #Update city names for q in qe: changed = self.api_obj.check_city(q.city) if changed: q.city = changed q.put()
def get_attendings(self, ev_id, user_id, fb_token=None): us = User.get_by_id(user_id) token = None fb_id = None if us is not None: fb_id = us.fb_id if Event.get_by_id(ev_id) is None: return 1 results = Attendings.query(Attendings.event_id == ev_id) return self.json_format_attendees(results, fb_token, fb_id, user_id)
def set_event_details(e_id, name, date, city, add, descr, host, url, attendees, price, category, source): event1 = Event() qry = event1.check_event_exist(e_id) or event1.check_event_exist_by_name(name) if qry is False: event1.id = e_id event1.name = name event1.date = date event1.city = city event1.address = add event1.description = descr event1.host = host event1.event_url = url event1.source = source if (attendees != "Unknown"): event1.attendees = attendees event1.price = price if category is not None: event1.category = category key = event1.put() return key else: # Update existing meetings! It could be changed or canceled! qry.name = name qry.date = date qry.city = city qry.address = add qry.description = descr qry.host = host qry.event_url = url qry.source = source qry.price = price if category is not None: qry.category = category results = Attendings.query(Attendings.event_id == qry.get_by_id(e_id)) if results is not None: qry.attendees = attendees + results.count() else: qry.attendees = attendees qry.put()