ICS: refactoring

This commit is contained in:
boyska 2018-06-24 00:48:40 +02:00
parent 632db0c37f
commit 96b06a686b

View file

@ -326,7 +326,8 @@ def talk_to_ics(talk):
if 'time' not in talk or 'duration' not in talk:
return None
e = ics.Event(
uid="%s@%d.hackmeeting.org\n" % (talk['id'], talk['day'].year),
uid="%s@%d.hackmeeting.org" % (talk['id'],
get_global_data()['startdate'].year),
name=talk['id'],
begin=talk['time'],
duration=datetime.timedelta(minutes=talk['duration']),
@ -335,9 +336,11 @@ def talk_to_ics(talk):
# ics.py has some problems with unicode
# unidecode replaces letters with their most similar ASCII counterparts
# (ie: accents get stripped)
e.description = unidecode.unidecode(talk['text'])
if 'text' in talk:
e.description = unidecode.unidecode(talk['text'])
e.url = pelican.settings['SCHEDULEURL'] + '#talk-' + talk['id']
if 'room' in talk:
e.location = talk['room']
return e