Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enrich the data of created events #186

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions outlook/indico_outlook/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from pprint import pformat

from lxml import html

Check failure on line 10 in outlook/indico_outlook/calendar.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F401)

outlook/indico_outlook/calendar.py:10:18: F401 `lxml.html` imported but unused
import requests
from requests.exceptions import RequestException, Timeout
from sqlalchemy.orm import joinedload
Expand Down Expand Up @@ -106,17 +107,35 @@
if event.is_deleted:
logger.debug('Ignoring %s for deleted event %s', entry.action.name, entry.event_id)
return True
location = strip_control_chars(event.room_name)
description = strip_control_chars(event.description)
event_url = event.external_url

location = (f'{event.room_name} ({event.venue_name})'
if event.venue_name and event.room_name
else (event.venue_name or event.room_name))

cal_description = []
if event.person_links:
speakers = [f'{x.full_name} ({x.affiliation})' if x.affiliation else x.full_name
for x in event.person_links]
alexiri marked this conversation as resolved.
Show resolved Hide resolved
cal_description.append(f'<p>Speakers: {', '.join(speakers)}</p>')
cal_description.append(event.description)
if event.external_url:
alexiri marked this conversation as resolved.
Show resolved Hide resolved
cal_description.append(f'<p><a href="{event.external_url}">{event.external_url}</a></p>')

# Try to add the VC room URL to the description, if there is one
for vc_room in event.vc_room_associations:
try:
cal_description.append(f'<p><a href="{vc_room.data.url}">{vc_room.data.url}</a></p>')
except AttributeError:
pass
alexiri marked this conversation as resolved.
Show resolved Hide resolved

data = {
'status': _get_status(user, event, settings),
'start': int(event.start_dt.timestamp()),
'end': int(event.end_dt.timestamp()),
'subject': strip_control_chars(event.title),
# XXX: the API expects 'body', we convert it below
'description': f'<a href="{event_url}">{event_url}</a><br><br>{description}',
'location': location,
'description': strip_control_chars('\n'.join(cal_description)),
'location': strip_control_chars(location),
'reminder_on': settings['reminder'],
'reminder_minutes': settings['reminder_minutes']
}
Expand Down
2 changes: 1 addition & 1 deletion outlook/indico_outlook/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def event_registration_form_deleted(self, registration_form, **kwargs):
self.logger.info('Registration removed (form deleted): removing %s in %s', registration.user, event)

def event_updated(self, event, changes, **kwargs):
if not changes.keys() & {'title', 'description', 'location_data'}:
if not changes.keys() & {'title', 'description', 'location_data', 'person_links'}:
return
for user in get_participating_users(event):
self.logger.info('Event data change: updating %s in %r', user, event)
Expand Down
Loading