python-caldav / caldav

Apache License 2.0
313 stars 91 forks source link

Adding attendees to an existing event, and removing attendees from an existing event #374

Closed seanmills1020 closed 5 months ago

seanmills1020 commented 5 months ago

Hello,

After creating an event with an array of attendees, is it possible to add attendees to this existing event, and remove attendees from this existing event?

tobixen commented 5 months ago

There is a method event.add_attendee, but I'm not sure how well tested it is. Please check and report back. You will have to do event.save() after adding an attendee.

There is currently no test code covering add_attendee. This is something I wrote up wrg of the "scheduling"-support (accepting calendar invites and things like that), but I realized that the test servers I had available did not have good enough support for scheduling, so this work was discontinued. I should try to continue working at it again at some point.

tobixen commented 5 months ago

There is no code for removing an attendee, but there is an event.change_attendee_status which may be used to indicate that some attendee is not coming.

Arguably, as long as adding participants and changing the status only involves changing the icalendar data, the logic does not belong in the caldav library but in the icalendar library. I think I added it because the methods should also accept a caldav.Principal object as the participant.

seanmills1020 commented 5 months ago

Hi Tobias,

Thank you for the prompt reply. What I may end up doing is deleting the event, then adding it back with the updated list of attendees.

tobixen commented 5 months ago

Consider this:

event.data = updated_data
event.save()

or

event.icalendar_component.add('ATTENDEE', ...)
event.save()

rather than

event.delete()
calendar.save_event(...)

I would anyway encourage you to try out event.add_attendee - if it doesn't work, I will fix it in the next minor release. If you decide to use it, I may decide to throw some unit tests on it.