Skip to content

Commit

Permalink
Fix for free-busy fbtype statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-react0r committed Dec 10, 2023
1 parent 96e5f68 commit 24d0d1f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master

## 3.2.0.a2

* Fix for free-busy `fbtype` statuses

## 3.2.0.a1

* Added free-busy report
Expand Down
4 changes: 2 additions & 2 deletions radicale/app/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def free_busy_report(base_prefix: str, path: str, xml_request: Optional[ET.Eleme

fbtype = None
if item.component_name == 'VEVENT':
transp = getattr(item.vobject_item, 'transp', None)
transp = getattr(item.vobject_item.vevent, 'transp', None)
if transp and transp.value != 'OPAQUE':
continue

status = getattr(item.vobject_item, 'status', None)
status = getattr(item.vobject_item.vevent, 'status', None)
if not status or status.value == 'CONFIRMED':
fbtype = 'BUSY'
elif status.value == 'CANCELLED':
Expand Down
36 changes: 36 additions & 0 deletions radicale/tests/static/event10.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
BEGIN:VCALENDAR
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Paris
X-LIC-LOCATION:Europe/Paris
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20130902T150157Z
LAST-MODIFIED:20130902T150158Z
DTSTAMP:20130902T150158Z
UID:event10
SUMMARY:Event
CATEGORIES:some_category1,another_category2
ORGANIZER:mailto:unclesam@example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=TENTATIVE;CN=Jane Doe:MAILTO:janedoe@example.com
ATTENDEE;ROLE=REQ-PARTICIPANT;DELEGATED-FROM="MAILTO:bob@host.com";PARTSTAT=ACCEPTED;CN=John Doe:MAILTO:johndoe@example.com
DTSTART;TZID=Europe/Paris:20130901T180000
DTEND;TZID=Europe/Paris:20130901T190000
STATUS:CANCELLED
END:VEVENT
END:VCALENDAR
10 changes: 7 additions & 3 deletions radicale/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ def test_report_free_busy(self) -> None:
"""Test free busy report on a few items"""
calendar_path = "/calendar.ics/"
self.mkcalendar(calendar_path)
for i in (1,2):
for i in (1,2,10):
filename = "event{}.ics".format(i)
event = get_file_content(filename)
self.put(posixpath.join(calendar_path, filename), event)
Expand All @@ -1382,9 +1382,13 @@ def test_report_free_busy(self) -> None:
assert isinstance(response, vobject.base.Component)
assert len(responses) == 1
vcalendar = list(responses.values())[0]
assert len(vcalendar.vfreebusy_list) == 2
assert len(vcalendar.vfreebusy_list) == 3
types = {}
for vfb in vcalendar.vfreebusy_list:
assert vfb.fbtype.value == 'BUSY'
if vfb.fbtype.value not in types:
types[vfb.fbtype.value] = 0
types[vfb.fbtype.value] += 1
assert types == {'BUSY':2, 'FREE':1}

def _report_sync_token(
self, calendar_path: str, sync_token: Optional[str] = None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# When the version is updated, a new section in the CHANGELOG.md file must be
# added too.
VERSION = "3.2.0.a1"
VERSION = "3.2.0.a2"

with open("README.md", encoding="utf-8") as f:
long_description = f.read()
Expand Down

0 comments on commit 24d0d1f

Please sign in to comment.