| | 491 | |
|---|
| | 492 | def export(self, private=False): |
|---|
| | 493 | """Exports the event as an icalendar.Event. |
|---|
| | 494 | |
|---|
| | 495 | Setting provate to True will hide all information except date/time |
|---|
| | 496 | information. This should be used for private events when exporting |
|---|
| | 497 | is done by somebody who does not have full rights to the event""" |
|---|
| | 498 | |
|---|
| | 499 | e = icalendar.Event() |
|---|
| | 500 | if not self.allday: |
|---|
| | 501 | e.add('dtstart', self.dtstart) |
|---|
| | 502 | # exporting duration directly instead of dtend |
|---|
| | 503 | # seems to confuse some clients, like KOrganizer, |
|---|
| | 504 | # so calculate dtend instead |
|---|
| | 505 | e.add('dtend', self.dtstart + self.duration) |
|---|
| | 506 | else: |
|---|
| | 507 | # all day event |
|---|
| | 508 | # create dtstart with VALUE=DATE property |
|---|
| | 509 | dtstart_prop = icalendar.vDate(self.dtstart.date()) |
|---|
| | 510 | dtstart_prop.params['VALUE'] = icalendar.vText('DATE') |
|---|
| | 511 | e.add('dtstart', dtstart_prop, encode=0) |
|---|
| | 512 | # now create dtend with VALUE=DATE property |
|---|
| | 513 | dtend = self.dtstart + self.duration |
|---|
| | 514 | dtend_prop = icalendar.vDate(dtend) |
|---|
| | 515 | dtend_prop.params['VALUE'] = icalendar.vText('DATE') |
|---|
| | 516 | e.add('dtend', dtend_prop, encode=0) |
|---|
| | 517 | if self.recurrence is not None: |
|---|
| | 518 | r = self.recurrence |
|---|
| | 519 | d = {'freq': r.ical_freq, 'interval': r.interval} |
|---|
| | 520 | if r.count is not None: |
|---|
| | 521 | d['count'] = r.count |
|---|
| | 522 | if r.until is not None: |
|---|
| | 523 | d['until'] = r.until |
|---|
| | 524 | e.add('rrule', icalendar.vRecur(d)) |
|---|
| | 525 | if self.transparent: |
|---|
| | 526 | e.add('transp', 'TRANSPARENT') |
|---|
| | 527 | else: |
|---|
| | 528 | e.add('transp', 'OPAQUE') |
|---|
| | 529 | if private: |
|---|
| | 530 | # Hide all non-time information as it may be sensitive. |
|---|
| | 531 | return e |
|---|
| | 532 | |
|---|
| | 533 | e.add('uid', self.unique_id) |
|---|
| | 534 | e.add('summary', self.title) |
|---|
| | 535 | if self.description: |
|---|
| | 536 | e.add('description', self.description) |
|---|
| | 537 | if self.location: |
|---|
| | 538 | e.add('location', self.location) |
|---|
| | 539 | if self.categories: |
|---|
| | 540 | e.set_inline('categories', list(self.categories)) |
|---|
| | 541 | e.add('class', self.access) |
|---|
| | 542 | if self.document: |
|---|
| | 543 | e.add('attach', self.document) |
|---|
| | 544 | e.add('status', self.status) |
|---|
| | 545 | return e |
|---|
| | 546 | |
|---|
| 892 | | e = icalendar.Event() |
|---|
| 893 | | e.add('uid', event.unique_id) |
|---|
| 894 | | e.add('summary', event.title) |
|---|
| 895 | | if event.transparent: |
|---|
| 896 | | e.add('transp', 'TRANSPARENT') |
|---|
| 897 | | else: |
|---|
| 898 | | e.add('transp', 'OPAQUE') |
|---|
| 899 | | if event.description: |
|---|
| 900 | | e.add('description', event.description) |
|---|
| 901 | | if not event.allday: |
|---|
| 902 | | e.add('dtstart', event.dtstart) |
|---|
| 903 | | # exporting duration directly instead of dtend |
|---|
| 904 | | # seems to confuse some clients, like KOrganizer, |
|---|
| 905 | | # so calculate dtend instead |
|---|
| 906 | | e.add('dtend', event.dtstart + event.duration) |
|---|
| 907 | | else: |
|---|
| 908 | | # all day event |
|---|
| 909 | | # create dtstart with VALUE=DATE property |
|---|
| 910 | | dtstart_prop = icalendar.vDate(event.dtstart.date()) |
|---|
| 911 | | dtstart_prop.params['VALUE'] = icalendar.vText('DATE') |
|---|
| 912 | | e.add('dtstart', dtstart_prop, encode=0) |
|---|
| 913 | | # now create dtend with VALUE=DATE property |
|---|
| 914 | | dtend = event.dtstart + event.duration |
|---|
| 915 | | dtend_prop = icalendar.vDate(dtend) |
|---|
| 916 | | dtend_prop.params['VALUE'] = icalendar.vText('DATE') |
|---|
| 917 | | e.add('dtend', dtend_prop, encode=0) |
|---|
| 918 | | if event.location: |
|---|
| 919 | | e.add('location', event.location) |
|---|
| 920 | | if event.categories: |
|---|
| 921 | | e.set_inline('categories', list(event.categories)) |
|---|
| 922 | | e.add('class', event.access) |
|---|
| 923 | | if event.document: |
|---|
| 924 | | e.add('attach', event.document) |
|---|
| 925 | | if event.recurrence is not None: |
|---|
| 926 | | r = event.recurrence |
|---|
| 927 | | d = {'freq': r.ical_freq, 'interval': r.interval} |
|---|
| 928 | | if r.count is not None: |
|---|
| 929 | | d['count'] = r.count |
|---|
| 930 | | if r.until is not None: |
|---|
| 931 | | d['until'] = r.until |
|---|
| 932 | | e.add('rrule', icalendar.vRecur(d)) |
|---|
| 933 | | e.add('status', event.status) |
|---|
| 934 | | # attendee needs email address info |
|---|
| | 950 | e = event.export() |
|---|