Commit 7990ea9a authored by Julian Rother's avatar Julian Rother

Implemented simple meeting importer that works with sogo and generates psas

parent e8f4e857
......@@ -185,6 +185,7 @@ CREATE TABLE IF NOT EXISTS `videos_data` (
);
CREATE TABLE IF NOT EXISTS `announcements` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`extid` varchar(128) UNIQUE,
`text` text NOT NULL DEFAULT '',
`level` INTEGER NOT NULL DEFAULT 0,
`visible` INTEGER NOT NULL DEFAULT 0,
......@@ -206,7 +207,6 @@ CREATE TABLE IF NOT EXISTS `featured` (
`time_updated` datetime NOT NULL,
`created_by` INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS `sortlog` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`when` datetime NOT NULL,
......
from server import *
import icalendar
import requests
def get_next_meeting():
ical = requests.get(config['ICAL_URL']).content
events = icalendar.Calendar.from_ical(ical).walk('VEVENT')
now = datetime.now().date()
delta = timedelta(weeks=2)
meetings = []
for event in events:
try:
start = event['DTSTART'].dt.date()
if 'VIDEO' != event['SUMMARY'].upper() or start < now or start > now+delta:
continue
meetings.append(event)
except:
pass
if not meetings:
return
event = sorted(meetings, key=lambda e: e['DTSTART'].dt)[0]
return str(event['UID']), event['DTSTART'].dt.replace(tzinfo=None)
def update_meeting():
try:
uid, start = get_next_meeting()
except:
return
text = 'Die nächste Video AG-Sitzung findet am %s ab %s Uhr in den Räumlichkeiten der Fachschaft im Augustinerbach 2a statt.'%(
human_date(start), human_time(start))
modify('''REPLACE INTO announcements
(extid, text, level, visible, time_publish, time_expire, time_created, time_updated, created_by)
VALUES (?, ?, 0, 1, ?, ?, ?, ?, 0)''',
'ical:'+uid, text, start-timedelta(days=3), start+timedelta(hours=2), datetime.now(), datetime.now())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment