def get_events(self): """ Return all future events """ now = datetime.combine(date.today(), datetime.min.time()) query = Event.query(Event.start_date >= now, Event.active == True) return query.order(Event.start_date).fetch(100)
def get_events(self): """ Return all future events """ now = datetime.combine(date.today(), datetime.min.time()) return Event.query(Event.start_date >= now).order( Event.start_date).fetch(100)
def get_events(self): """ Return all future events in the string theory junior seminar series """ now = datetime.combine(date.today(), datetime.min.time()) query = Event.query(Event.series == 'Strings Junior Seminar', Event.start_date >= now, Event.active == True) return query.order(Event.start_date).fetch(100)
def get_events(self): """ Return all future events in the string theory junior seminar series """ now = datetime.combine(date.today(), datetime.min.time()) query = Event.query( Event.series == 'Strings Junior Seminar', Event.start_date >= now, Event.active == True) return query.order(Event.start_date).fetch(100)
def get_event(self, key_id): if key_id is not None: return Event.get_by_id(int(key_id)) uid = str(uuid.uuid4()) ev = Event(uid=uid, editable=True, active=True) ev.start_date = datetime.utcnow() ev.end_date = datetime.utcnow() ev.put() return ev
def get_events(self): last_saturday = self.get_start_date() next_saturday = last_saturday + timedelta(weeks=1) t0 = datetime.combine(last_saturday, datetime.min.time()) t1 = datetime.combine(next_saturday, datetime.max.time()) # allow for week-spanning events would be ideally: # query = Event.query(Event.start_date <= t1, Event.end_date >= t0) # but inequality queries can currently be only on one property query = Event.query(Event.start_date >= t0, Event.start_date < t1, Event.active == True) return query.order(Event.start_date).fetch(100)
def get_events(self): last_saturday = self.get_start_date() next_saturday = last_saturday + timedelta(weeks=1) t0 = datetime.combine(last_saturday, datetime.min.time()) t1 = datetime.combine(next_saturday, datetime.max.time()) # allow for week-spanning events would be ideally: # query = Event.query(Event.start_date <= t1, Event.end_date >= t0) # but inequality queries can currently be only on one property query = Event.query( Event.start_date >= t0, Event.start_date < t1, Event.active == True) return query.order(Event.start_date).fetch(100)
def expire_deleted_events(self): max_unseen = timedelta(days=2) now = datetime.utcnow() query = Event.query(Event.start_date > now) events = query.fetch(1000) log = self.response.write log('=' * 80) log(u'Total: {} events\n'.format(len(events))) for ev in events: if ev.seen is None: log(u'{}: seen is None, deleting\n'.format(ev.speaker)) ev.key.delete() continue age = now - ev.seen if age > max_unseen: log(u'{}: age = {} > {}, deleting.\n'.format(ev.speaker, age, max_unseen)) ev.key.delete() continue log(u'{}: is current, keeping.\n'.format(ev.speaker))
def expire_deleted_events(self): max_unseen = timedelta(days=2) now = datetime.utcnow() query = Event.query(Event.start_date > now) events = query.fetch(1000) log = self.response.write log('=' * 80) log(u'Total: {} events\n'.format(len(events))) for ev in events: if ev.seen is None: log(u'{}: seen is None, deleting\n'.format(ev.speaker)) ev.key.delete() continue age = now - ev.seen if age > max_unseen: log(u'{}: age = {} > {}, deleting.\n'.format( ev.speaker, age, max_unseen)) ev.key.delete() continue log(u'{}: is current, keeping.\n'.format(ev.speaker))
def get(self): from icalendar import Calendar, Event, vCalAddress, vText cal = Calendar() cal.add('prodid', '-//Strings Oxford Calendaring//strings.ox.ac.uk//') cal.add('version', '2.0') cal.add('X-WR-CALNAME', 'Strings Oxford') for ev in self.get_events(): event = Event() event['uid'] = vText(ev.uid) event['location'] = vText(ev.location) event['summary'] = ev.title event['dtstart'] = self._ical_time(ev.start_date) event['dtend'] = self._ical_time(ev.end_date) desc = u'Speaker: {}\n'.format(ev.speaker) desc += u'Location: {}\n'.format(ev.location) desc += u'Series: {}\n'.format(ev.series) desc += ev.description event['description'] = vText(desc) cal.add_component(event) #self.response.headers['Content-Type'] = 'text/plain' self.response.headers['Content-Type'] = 'text/calendar' self.response.write(cal.to_ical())
def save(self): """ Save to app engine datastore """ from app.event_model import Event ev = Event.query(Event.uid == self.uid).fetch(1) if len(ev) == 0: active = self.active_by_default or ( self.series.lower() in config.default_series_lower_case) ev = Event(uid=self.uid, editable=False, active=active) else: ev = ev[0] ev.source = self.source ev.start_date = self.start_date ev.end_date = self.end_date ev.author = self.author ev.series = self.series ev.location = self.location ev.speaker = self.speaker ev.title = self.title ev.description = self.description ev.seen = datetime.utcnow() ev.put()
def get_events(self): """ Return all future events """ now = datetime.combine(date.today(), datetime.min.time()) return Event.query(Event.start_date >= now).order(Event.start_date).fetch(100)
def post(self): key_id = self.request.get('key_id') active = (self.request.get('active') == u'true') ev = Event.get_by_id(int(key_id)) ev.active = active ev.put()