def currentOrgs(self): """ Returns a list of organizations with current events that want community calendar links """ today = datetime.date.today() som = caldate.startOfMonth(today).isoformat() eom = caldate.endOfMonth(today).isoformat() # query = """ # SELECT DISTINCT o.oid, o.name AS orgname, o.alt_cal_url, o.acronym # FROM EvDates ev, Events e, Orgs o # WHERE # ev.sdate >= "%s" # AND ev.edate <= "%s" # AND ev.eid = e.eid # AND o.oid = e.oid # AND o.ccal_link =1 # ORDER BY orgname # """ % (som, eom) query = """ SELECT DISTINCT o.oid, o.name AS orgname, o.alt_cal_url, o.acronym FROM Orgs o WHERE o.ccal_link =1 ORDER BY orgname """ return Results(self.reader.query(query))
def eventList(self): """ get events in a simple list, based on params. list format [(date, eventdict),...] """ target = self.params.get('date', self.today) mode = self.params.get('mode', 'month') if mode == 'day': edict = self.eventsByDay(target, target) elif mode == 'week': edict = self.eventsByDay(caldate.startOfWeek(target), caldate.endOfWeek(target)) elif mode == 'upcoming': end = self.today + timedelta(self.params.get('days', 30)) edict = self.eventsByDay(self.today, end) else: edict = self.eventsByDay(caldate.startOfMonth(target), caldate.endOfMonth(target)) keys = edict.keys() keys.sort() elist = [] for key in keys: elist.append([key, edict[key]]) return elist