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

Support CalendarItem recurrences #37

Closed
ecederstrand opened this issue Nov 20, 2016 · 13 comments
Closed

Support CalendarItem recurrences #37

ecederstrand opened this issue Nov 20, 2016 · 13 comments

Comments

@ecederstrand
Copy link
Owner

ecederstrand commented Nov 20, 2016

exchangelib doesn't yet support getting, setting or changing recurrence info on recurring calendar items.

Short introduction with examples: https://msdn.microsoft.com/en-us/library/office/dn727654(v=exchg.150).aspx
Reference: https://msdn.microsoft.com/en-us/library/office/aa580471(v=exchg.150).aspx

@jkottapa
Copy link

jkottapa commented Feb 8, 2017

Hi Eric, I am interested in this enhancement. Is there anything that I can do to help, if you have already started on the implementation, are there any commits that I have a look at it to see if I can figure it out?

@ecederstrand
Copy link
Owner Author

Hi @Jayanth1991

I started but have just implemented parts of the necessary XML elements. What is needed is adding a recursion field to CalendarItem and lots of XML generation and parsing to read and produce the XML, and possibly a more user friendly API to create recurring items.

I'll commit my WIP in a branch tonight so you can have a look. Thanks!

@ecederstrand
Copy link
Owner Author

There's now a branch with the WIP: https://github.com/ecederstrand/exchangelib/tree/37_recurrence-support

Please post any progress here :-) Maybe it's easiest to start by just parsing recursion info on existing CalendarItems on the server.

@agentq15
Copy link

How is the work going with this? I can't get recurring items right now and almost all of my appointments are recurring.

@ecederstrand
Copy link
Owner Author

ecederstrand commented Feb 23, 2017

There's a branch with the current state, which is non-functional still. However, if you just need to view your appointments, there's the account.calendar.view(start, end) method which returns the recurring calendar items unfolded.

@agentq15
Copy link

Thank you, that method worked perfectly for my purpose :)

@sedemmler
Copy link

sedemmler commented Feb 28, 2017

Am I just missing the function for accepting Calendar invitations or would that be on a separate branch? I love this repo, by the way. Thank you.

@ecederstrand
Copy link
Owner Author

Meeting invitations are only barely supported, meaning that exchangelib doesn't crash when encountering one in a folder. But there is no support yet for reading or answering meeting requests, cancellations or responses. Have a look at the Meeting* classes in exchangelib.folders if you want to give this a stab. It's a bit difficult for me to test ATM since my test server only has one account.

@sedemmler
Copy link

I'm happy to have a go at it.

@ecederstrand
Copy link
Owner Author

Cool. I opened #89 to track this, as it doesn't really have anything to do with calendar recurrences.

@ecederstrand
Copy link
Owner Author

There's now rudimentary support for reading recurring item info in the 37_recurrence-support branch

TODO: tests, write support, a simple API for creating recurrences, and docs

@ecederstrand
Copy link
Owner Author

ecederstrand commented Jun 19, 2017

We should now have full read-write recurrence support. There's support for creating daily, weekly, monthly and yearly recurrences (the latter two in relative and absolute versions). Everything is implemented in https://github.com/ecederstrand/exchangelib/blob/master/exchangelib/recurrence.py

Here's an example of creating 7 occurrences on Mondays and Wednesdays of every third week, starting September 1, 2017:

from exchangelib import CalendarItem, EWSDateTime, EWSTimeZone, EWSDate
from exchangelib.recurrence import Recurrence, WeeklyPattern, MONDAY, WEDNESDAY

item = CalendarItem(
    folder=a.calendar,
    start=tz.localize(EWSDateTime(2017, 9, 1, 11)),
    end=tz.localize(EWSDateTime(2017, 9, 1, 13)),
    subject='Hello Recurrence',
    recurrence=Recurrence(
        pattern=WeeklyPattern(interval=3, weekdays=[MONDAY, WEDNESDAY]), 
        start=EWSDate(2017, 9, 1), 
        number=7
    ),
)

# Occurrence data for the master item
for i in a.calendar.filter(start__lt=end, end__gt=start):
    print(i.subject, i.start, i.end)
    print(i.recurrence)
    print(i.first_occurrence)
    print(i.last_occurrence)
    for o in i.modified_occurrences:
        print(o)
    for o in i.deleted_occurrences:
        print(o)

# All occurrences expanded
for i in a.calendar.view(start=end, end=start):
    print(i.subject, i.start, i.end)

This is to be considered an experimental feature for now. Please play around with it and see if it does what you want. I'd like this to settle a bit before setting the API and functionality in stone in a release. Thanks.

@ecederstrand
Copy link
Owner Author

Tests added in 99b5770 I now consider this ready for general consumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants