Skip to content

Commit a8c8a09

Browse files
committed
Add support for event labels
1 parent 2dc09ad commit a8c8a09

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

outlook/indico_outlook/calendar.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ def _update_calendar_entry(entry, settings):
127127
if event.venue_name and event.room_name
128128
else (event.venue_name or event.room_name))
129129

130+
title = event.title
131+
if event.label:
132+
title = f'[{event.label.title}] {title}'
133+
130134
cal_description = []
131135
if event.person_links:
132136
speakers = [f'{x.full_name} ({x.affiliation})' if x.affiliation else x.full_name
@@ -139,7 +143,7 @@ def _update_calendar_entry(entry, settings):
139143
'status': _get_status(user, event, settings),
140144
'start': int(event.start_dt.timestamp()),
141145
'end': int(event.end_dt.timestamp()),
142-
'subject': strip_control_chars(event.title),
146+
'subject': strip_control_chars(title),
143147
# XXX: the API expects 'body', we convert it below
144148
'description': strip_control_chars('\n<br>\n'.join(cal_description)),
145149
'location': strip_control_chars(location),

outlook/indico_outlook/plugin.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,22 @@ def event_registration_form_deleted(self, registration_form, **kwargs):
316316
self.logger.info('Registration removed (form deleted): removing %s in %s', registration.user, event)
317317

318318
def event_updated(self, event, changes, **kwargs):
319-
monitored_keys = {'title', 'description', 'location_data', 'person_links', 'start_dt', 'end_dt', 'duration'}
319+
monitored_keys = {'title', 'description', 'location_data', 'person_links',
320+
'start_dt', 'end_dt', 'duration', 'label'}
320321
if not changes.keys() & monitored_keys:
321322
return
322323

324+
if 'label' in changes:
325+
(old_label, new_label) = changes['label']
326+
# If the event is not happening, treat this as a deletion
327+
if new_label and new_label.is_event_not_happening:
328+
self.event_deleted(event, **kwargs)
329+
return
330+
# If the event wasn't happening before but it is now, treat this as a creation
331+
if new_label and not new_label.is_event_not_happening and old_label and old_label.is_event_not_happening:
332+
self.event_created(event, **kwargs)
333+
return
334+
323335
users_to_update = set()
324336
# Registered users need to be informed about changes
325337
for user in get_registered_users(event):

0 commit comments

Comments
 (0)