This commit is contained in:
parent
29c6723867
commit
7ab46bc48e
|
@ -15,6 +15,18 @@ ZERO_DURATION = datetime.timedelta(seconds=0)
|
||||||
HOUR = datetime.timedelta(hours=1)
|
HOUR = datetime.timedelta(hours=1)
|
||||||
MINUTE = datetime.timedelta(minutes=1)
|
MINUTE = datetime.timedelta(minutes=1)
|
||||||
|
|
||||||
|
|
||||||
|
def create_title(sample: RealizedWorkSample) -> str:
|
||||||
|
ls = []
|
||||||
|
for label_and_type in sample.labels:
|
||||||
|
if label_and_type.startswith(HIDDEN_LABEL_PREFIX):
|
||||||
|
continue
|
||||||
|
if label_and_type.startswith('author:'):
|
||||||
|
continue
|
||||||
|
ls.append(label_and_type)
|
||||||
|
return ' '.join(ls)
|
||||||
|
|
||||||
|
|
||||||
def generate_calendar(
|
def generate_calendar(
|
||||||
samples: list[RealizedWorkSample],
|
samples: list[RealizedWorkSample],
|
||||||
) -> icalendar.Calendar:
|
) -> icalendar.Calendar:
|
||||||
|
@ -26,7 +38,7 @@ def generate_calendar(
|
||||||
|
|
||||||
for sample in samples:
|
for sample in samples:
|
||||||
|
|
||||||
title = ' '.join(sample.labels)
|
title = create_title(sample)
|
||||||
|
|
||||||
description = ''
|
description = ''
|
||||||
|
|
||||||
|
@ -38,6 +50,10 @@ def generate_calendar(
|
||||||
event.add('dtstart', sample.start_at)
|
event.add('dtstart', sample.start_at)
|
||||||
event.add('dtend', sample.end_at)
|
event.add('dtend', sample.end_at)
|
||||||
|
|
||||||
|
for label_and_type in sample.labels:
|
||||||
|
if label_and_type.startswith('author:'):
|
||||||
|
event.add('organizer', 'mailto:'+label_and_type.removeprefix('author:'))
|
||||||
|
|
||||||
cal.add_component(event)
|
cal.add_component(event)
|
||||||
del event
|
del event
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user