@@ -190,11 +190,8 @@ def expand_rrule(
190190 RRULE set and into a "recurrence set" with RECURRENCE-ID set
191191 and no RRULE set. The main usage is for client-side expansion
192192 in case the calendar server does not support server-side
193- expansion. It should be safe to save back to the server, the
194- server should recognize it as recurrences and should not edit
195- the "master copy". If doing a `self.load`, the calendar
196- content will be replaced with the "master copy". However, as
197- of 2022-10 there is no test code verifying this.
193+ expansion. If doing a `self.load`, the calendar
194+ content will be replaced with the "master copy".
198195
199196 :param event: Event
200197 :param start: datetime
@@ -206,24 +203,16 @@ def expand_rrule(
206203 recurrings = recurring_ical_events .of (
207204 self .icalendar_instance , components = ["VJOURNAL" , "VTODO" , "VEVENT" ]
208205 ).between (start , end )
209- recurrence_properties = ["exdate" , "exrule" , "rdate" , "rrule" ]
210- # FIXME too much copying
211- stripped_event = self .copy (keep_uid = True )
212-
213- ## TODO: use icalendar_instance instead
214- if stripped_event .vobject_instance is None :
215- raise ValueError (
216- "Unexpected value None for stripped_event.vobject_instance"
217- )
218206
219- # remove all recurrence properties
220- for component in stripped_event .vobject_instance .components (): # type: ignore
221- if component .name in ("VEVENT" , "VTODO" ):
222- for key in recurrence_properties :
223- try :
224- del component .contents [key ]
225- except KeyError :
226- pass
207+ recurrence_properties = {"exdate" , "exrule" , "rdate" , "rrule" }
208+
209+ if any (
210+ x for x in recurrings if not recurrence_properties .isdisjoint (set (x .keys ()))
211+ ):
212+ ## I think we should not end up here. And if we do, then it's needed to reinsert the code section I just removed ...
213+ import pdb
214+
215+ pdb .set_trace ()
227216
228217 calendar = self .icalendar_instance
229218 calendar .subcomponents = []
@@ -236,12 +225,12 @@ def expand_rrule(
236225 ):
237226 continue
238227 if "RECURRENCE-ID" not in occurrence :
239- occurrence .add ("RECURRENCE-ID" , occurrence .get ("DTSTART" ))
228+ ## we should not get here?
229+ import pdb
230+
231+ pdb .set_trace ()
232+ occurrence .add ("RECURRENCE-ID" , occurrence .get ("DTSTART" ).dt )
240233 calendar .add_component (occurrence )
241- # add other components (except for the VEVENT itself and VTIMEZONE which is not allowed on occurrence events)
242- for component in stripped_event .icalendar_instance .subcomponents :
243- if component .name not in ("VEVENT" , "VTODO" , "VTIMEZONE" ):
244- calendar .add_component (component )
245234
246235 def set_relation (
247236 self , other , reltype = None , set_reverse = True
@@ -1394,11 +1383,11 @@ def uncomplete(self) -> None:
13941383 """Undo completion - marks a completed task as not completed"""
13951384 ### TODO: needs test code for code coverage!
13961385 ## (it has been tested through the calendar-cli test code)
1397- if not hasattr ( self . vobject_instance . vtodo , "status" ) :
1398- self .vobject_instance . vtodo . add ("status" )
1399- self .vobject_instance . vtodo . status . value = "NEEDS-ACTION"
1400- if hasattr ( self . vobject_instance . vtodo , "completed" ) :
1401- self .vobject_instance . vtodo . remove ( self . vobject_instance . vtodo . completed )
1386+ if "status" in self . icalendar_component :
1387+ self .icalendar_component . pop ("status" )
1388+ self .icalendar_component . add ( " status" , "NEEDS-ACTION" )
1389+ if "completed" in self . icalendar_component :
1390+ self .icalendar_component . pop ( " completed" )
14021391 self .save ()
14031392
14041393 ## TODO: should be moved up to the base class
0 commit comments