Skip to content

Commit

Permalink
Let tasks have NEEDS-ACTION as default status when creating them (sor…
Browse files Browse the repository at this point in the history
…t of a workaround for DAViCal)
  • Loading branch information
tobixen committed Feb 15, 2023
1 parent ffb71a5 commit 5ce989a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions caldav/lib/vcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ def create_ical(ical_fragment=None, objtype=None, language="en_DK", **props):
if not props.get("uid") and not "\nUID:" in (ical_fragment or ""):
component.add("uid", uuid.uuid1())
my_instance.add_component(component)
## STATUS should default to NEEDS-ACTION for tasks, if it's not set
## (otherwise we cannot easily add a task to a davical calendar and
## then find it again - ref https://gitlab.com/davical-project/davical/-/issues/281
if (
not props.get("STATUS")
and not "\nSTATUS:" in (ical_fragment or "")
and objtype == "VTODO"
):
props["STATUS"] = "NEEDS-ACTION"

else:
if not ical_fragment.strip().startswith("BEGIN:VCALENDAR"):
ical_fragment = (
Expand All @@ -152,6 +162,7 @@ def create_ical(ical_fragment=None, objtype=None, language="en_DK", **props):
my_instance = icalendar.Calendar.from_ical(ical_fragment)
component = my_instance.subcomponents[0]
ical_fragment = None

for prop in props:
if props[prop] is not None:
if isinstance(props[prop], datetime.datetime) and not props[prop].tzinfo:
Expand Down

0 comments on commit 5ce989a

Please sign in to comment.