Skip to content

Commit

Permalink
Raise exception on non-existing event; update full event
Browse files Browse the repository at this point in the history
  • Loading branch information
dhomeier committed Jun 22, 2024
1 parent bcb2b6d commit 80c0936
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ async def update_event(self, uid: str, updates: dict):
"autoAccept": False,
"payment": {},
"attachments": [],
"id": None,
"tasks": {
"openTasks": [],
"assignedTasks": [
Expand All @@ -374,10 +373,19 @@ async def update_event(self, uid: str, updates: dict):
},
}

if not self.events:
await self.get_events()
for event in self.events:
if event["id"] == uid:
base_event.update(event)
url = f"{self.API_BASE_URL}sponds/{uid}"
break
else:
errmsg = f"No event with id='{uid}' existing"
raise ValueError(errmsg)

for key in base_event:
if event.get(key) is not None and not updates.get(key):
base_event[key] = event[key]
elif updates.get(key) is not None:
if updates.get(key) is not None:
base_event[key] = updates[key]

data = dict(base_event)
Expand Down

0 comments on commit 80c0936

Please sign in to comment.