Pārlūkot izejas kodu

Fix UserCal to always use CalDAV backend regardless of store.active

UserCal reads from the user's personal 'House' calendar which is always
CalDAV. Going through get_backend() caused it to silently write to SQLite
in sqlite mode, so user_cal.set calls had no effect and reservations never
appeared in the House calendar.
ZiB 4 mēneši atpakaļ
vecāks
revīzija
7088b8b013
1 mainītis faili ar 3 papildinājumiem un 0 dzēšanām
  1. 3 0
      room_cal/user_cal/__init__.py

+ 3 - 0
room_cal/user_cal/__init__.py

@@ -1,6 +1,7 @@
 import json
 from datetime import date
 from room_cal.store import StoreBacked
+from room_cal.store._caldav import CalDAVBackend, get_calendar
 from room_cal._utils import EventSource, safe_json_loads, services as _services, service_name
 
 DEFAULT_CALENDAR_NAME = 'House'
@@ -9,6 +10,8 @@ _ROOM_CLOSED_TITLE = 'Room Closed'
 
 class UserCal(StoreBacked, EventSource):
   def __init__(self, calendar_name: str = DEFAULT_CALENDAR_NAME, *, backend=None):
+    if backend is None:
+      backend = CalDAVBackend(get_calendar(calendar_name))
     StoreBacked.__init__(self, calendar_name, backend=backend)
     EventSource.__init__(self, 'user_cal')